From 0d6a49aafc24119b3baeb80ad25343c8ffeb2bfb Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Wed, 20 Oct 2021 17:24:40 +0300 Subject: [PATCH 1/9] Lwm2m front base64 tooltip --- .../device-credentials-lwm2m-server.component.html | 7 +++++++ .../device/device-credentials-lwm2m.component.html | 14 +++++++++++--- .../lwm2m-device-config-server.component.html | 7 ++++++- ...-profile-transport-configuration.component.html | 4 ++-- .../src/assets/locale/locale.constant-cs_CZ.json | 1 - .../src/assets/locale/locale.constant-en_US.json | 13 +++++++++---- .../src/assets/locale/locale.constant-tr_TR.json | 1 - 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html index 3c3806882f..d9f08787b6 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html @@ -32,6 +32,9 @@ cdkAutosizeMinRows="1" cols="1" formControlName="clientPublicKeyOrId" + matTooltip="{{ 'device.lwm2m-security-config.client-publicKey-or-id-tooltip' | translate: + {count: serverFormGroup.get('securityMode').value === securityConfigLwM2MType.PSK? 0 : + serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK? 1 : 2} }}" required> @@ -45,6 +48,10 @@ cdkAutosizeMinRows="1" cols="1" formControlName="clientSecretKey" + matTooltip="{{ 'device.lwm2m-security-config.client-secret-key-tooltip' | translate: + {count: serverFormGroup.get('securityMode').value === securityConfigLwM2MType.PSK? 0 : + serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK? 1 : 2} }}" + matTooltipPosition="below" required> diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html index b10eaf68ae..5833e33934 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html @@ -34,9 +34,12 @@ - + {{ 'device.lwm2m-security-config.identity' | translate }} - + {{ 'device.lwm2m-security-config.identity-required' | translate }} @@ -49,7 +52,10 @@ cdkAutosizeMinRows="1" cols="1" formControlName="key" - required> + required + matTooltip="{{ 'device.lwm2m-security-config.client-key-tooltip' | translate:{count: + lwm2mConfigFormGroup.get('client.securityConfigClientMode').value === securityConfigLwM2MType.PSK?0:1} }}" + matTooltipPosition="below"> {{ 'device.lwm2m-security-config.client-key-required' | translate }} @@ -61,6 +67,8 @@ cdkTextareaAutosize cdkAutosizeMinRows="1" cols="1" + matTooltip="{{ 'device.lwm2m-security-config.client-public-key-tooltip' | translate: {count: lwm2mConfigFormGroup.get('client.cert').value?1:2} }}" + matTooltipPosition="below" formControlName="cert"> device.lwm2m-security-config.client-public-key-hint diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html index 9c2ce132d8..9606883368 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html @@ -99,7 +99,12 @@ cdkAutosizeMinRows="1" cols="1" required formControlName="serverPublicKey" - > + matTooltip="{{ 'device.lwm2m-security-config.client-publicKey-or-id-tooltip' | translate: + {count: serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK? 1 : 2} }}" + matTooltipPosition="below" + required> + + {{ 'device-profile.lwm2m.server-public-key-required' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html index 5e444f8ee2..a514891e09 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html @@ -31,13 +31,13 @@ - +
- {{ 'device-profile.lwm2m.servers' | translate }} + {{ 'device-profile.lwm2m.security' | translate }}
diff --git a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json index 4e1ec64412..97bc94b645 100644 --- a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json +++ b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json @@ -1258,7 +1258,6 @@ "view-attribute": "Zobrazit atribut", "remove-attribute": "Odebrat atribut", "mode": "Režim konfigurace bezpečnosti", - "servers": "Servery", "short-id": "Krátké ID", "short-id-required": "Krátké ID je povinné.", "short-id-range": "Krátké ID by mělo být v rozsahu od 1 do 65534.", diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 4bbde6c029..91dfca6955 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -963,10 +963,15 @@ "lwm2m-security-config": { "identity": "Client Identity", "identity-required": "Client Identity is required.", + "identity-tooltip": "PSK identity is arbitrary PSK Identities of up to 128 bytes, as mandated in [RFC7925]. \n PSK identity MUST be first converted to a character string, and then encoded to octets using UTF-8 [UTF8].", "client-key": "Client Key", "client-key-required": "Client Key is required.", + "client-key-tooltip": "{ count, plural, 1 {RPK public key or id should be in RFC7250 standard and encoded to Base64 format!} other {PSK key should be in RFC4279 standard and HexDec format: 32, 64, 128 characters!.} }", "endpoint": "Endpoint Client Name", "endpoint-required": "Endpoint Client Name is required.", + "client-public-key": "Client public key", + "client-public-key-hint": "If client public key is empty, the trusted certificate will be used", + "client-public-key-tooltip": "{ count, plural, 1 {X509 public key should be in DER-encoded X509v3 format and support only EC algorithm and encoded to Base64 format!} other {} }", "mode": "Security config mode", "client-tab": "Client Security Config", "client-certificate": "Client certificate", @@ -975,10 +980,10 @@ "lwm2m-server": "LwM2M Server", "client-publicKey-or-id": "Client Public Key or Id", "client-publicKey-or-id-required": "Client Public Key or Id is required.", + "client-publicKey-or-id-tooltip": "{ count, plural, 0 {PSK identity is arbitrary PSK Identities of up to 128 bytes, as mandated in [RFC7925]. \n PSK identity MUST be first converted to a character string, and then encoded to octets using UTF-8 [UTF8].} 1 {RPK public key or id should be in RFC7250 standard and encoded to Base64 format!} other {X509 public key should be in DER-encoded X509v3 format and support only EC algorithm and encoded to Base64 format!} }", "client-secret-key": "Client Secret Key", "client-secret-key-required": "Client Secret Key is required.", - "client-public-key": "Client public key", - "client-public-key-hint": "If client public key is empty, the trusted certificate will be used" + "client-secret-key-tooltip": "{ count, plural, 0 {PSK key should be in RFC4279 standard and HexDec format: 32, 64, 128 characters!.} 1 {RPK secret key should be in PKCS_8 format (DER encoding, RFC5958 standard) and encoded to Base64 format!} other {X509 secret key should be in PKCS_8 format (DER encoding, RFC5958 standard) and encoded to Base64 format!} }" }, "client-id": "Client ID", "client-id-pattern": "Contains invalid character.", @@ -1272,7 +1277,8 @@ "view-attribute": "View attribute", "remove-attribute": "Remove attribute", "mode": "Security config mode", - "servers": "Servers", + "security": "Securities", + "bootstrap-tab": "Bootstrap", "short-id": "Short ID", "short-id-required": "Short ID is required.", "short-id-range": "Short ID should be in a range from 1 to 65534.", @@ -1297,7 +1303,6 @@ "s": "S: SMS connection in standard mode", "sq": "SQ: SMS connection in queue mode" }, - "bootstrap-tab": "Bootstrap", "bootstrap-server": "Bootstrap Server", "lwm2m-server": "LwM2M Server", "server-host": "Host", diff --git a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json index c600cb0c9a..3bca05e458 100644 --- a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json +++ b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json @@ -1271,7 +1271,6 @@ "view-attribute": "Öznitelik görüntüle", "remove-attribute": "Öznitelik kaldır", "mode": "Güvenlik yapılandırma modu", - "servers": "Sunucular", "short-id": "Kısa ID", "short-id-required": "Kısa ID gerekli.", "short-id-range": "Kısa ID 1 ile 65534 aralığında olmalıdır.", From 0341c25d1a97ac7b5f3e2f7284403109ba2ec982 Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Wed, 27 Oct 2021 12:35:38 +0300 Subject: [PATCH 2/9] Lwm2m update text PSK identity --- ui-ngx/src/assets/locale/locale.constant-en_US.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 91dfca6955..716be68599 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -963,7 +963,7 @@ "lwm2m-security-config": { "identity": "Client Identity", "identity-required": "Client Identity is required.", - "identity-tooltip": "PSK identity is arbitrary PSK Identities of up to 128 bytes, as mandated in [RFC7925]. \n PSK identity MUST be first converted to a character string, and then encoded to octets using UTF-8 [UTF8].", + "identity-tooltip": "The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standart [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.", "client-key": "Client Key", "client-key-required": "Client Key is required.", "client-key-tooltip": "{ count, plural, 1 {RPK public key or id should be in RFC7250 standard and encoded to Base64 format!} other {PSK key should be in RFC4279 standard and HexDec format: 32, 64, 128 characters!.} }", From 4b6f7963cf3c6e2ec33ba0f017d4f8140b7b802d Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Wed, 27 Oct 2021 16:27:13 +0300 Subject: [PATCH 3/9] Lwm2m update text RPK and x509 --- ui-ngx/src/assets/locale/locale.constant-en_US.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 716be68599..5c4333f76c 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -963,15 +963,15 @@ "lwm2m-security-config": { "identity": "Client Identity", "identity-required": "Client Identity is required.", - "identity-tooltip": "The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standart [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.", + "identity-tooltip": "The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standard [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.", "client-key": "Client Key", "client-key-required": "Client Key is required.", - "client-key-tooltip": "{ count, plural, 1 {RPK public key or id should be in RFC7250 standard and encoded to Base64 format!} other {PSK key should be in RFC4279 standard and HexDec format: 32, 64, 128 characters!.} }", + "client-key-tooltip": "{ count, plural, 1 {RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!} other {PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!} }", "endpoint": "Endpoint Client Name", "endpoint-required": "Endpoint Client Name is required.", "client-public-key": "Client public key", "client-public-key-hint": "If client public key is empty, the trusted certificate will be used", - "client-public-key-tooltip": "{ count, plural, 1 {X509 public key should be in DER-encoded X509v3 format and support only EC algorithm and encoded to Base64 format!} other {} }", + "client-public-key-tooltip": "{ count, plural, 1 {X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format!} other {} }", "mode": "Security config mode", "client-tab": "Client Security Config", "client-certificate": "Client certificate", @@ -980,10 +980,10 @@ "lwm2m-server": "LwM2M Server", "client-publicKey-or-id": "Client Public Key or Id", "client-publicKey-or-id-required": "Client Public Key or Id is required.", - "client-publicKey-or-id-tooltip": "{ count, plural, 0 {PSK identity is arbitrary PSK Identities of up to 128 bytes, as mandated in [RFC7925]. \n PSK identity MUST be first converted to a character string, and then encoded to octets using UTF-8 [UTF8].} 1 {RPK public key or id should be in RFC7250 standard and encoded to Base64 format!} other {X509 public key should be in DER-encoded X509v3 format and support only EC algorithm and encoded to Base64 format!} }", + "client-publicKey-or-id-tooltip": "{ count, plural, 0 {The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standard [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.} 1 {RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!} other {X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format!} }", "client-secret-key": "Client Secret Key", "client-secret-key-required": "Client Secret Key is required.", - "client-secret-key-tooltip": "{ count, plural, 0 {PSK key should be in RFC4279 standard and HexDec format: 32, 64, 128 characters!.} 1 {RPK secret key should be in PKCS_8 format (DER encoding, RFC5958 standard) and encoded to Base64 format!} other {X509 secret key should be in PKCS_8 format (DER encoding, RFC5958 standard) and encoded to Base64 format!} }" + "client-secret-key-tooltip": "{ count, plural, 0 {PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!} 1 {RPK secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!} other {X509 secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!} }" }, "client-id": "Client ID", "client-id-pattern": "Contains invalid character.", From f14a966cc6a6c05297d30c6294a8a64ded13575e Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Wed, 3 Nov 2021 13:52:42 +0200 Subject: [PATCH 4/9] lwm2m - Biding mode for lwm2m V_1.1 --- .../lwm2m-device-config-server.component.html | 3 +- ...ile-transport-configuration.component.html | 217 ++++++++++++------ .../lwm2m/lwm2m-profile-config.models.ts | 22 +- .../assets/locale/locale.constant-cs_CZ.json | 14 -- .../assets/locale/locale.constant-en_US.json | 31 +-- .../assets/locale/locale.constant-tr_TR.json | 12 - 6 files changed, 173 insertions(+), 126 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html index 9606883368..b481c9a24a 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html @@ -51,7 +51,8 @@
{{ 'device-profile.lwm2m.short-id' | translate }} - + {{ 'device-profile.lwm2m.short-id-required' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html index a514891e09..b58546cf70 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html @@ -35,84 +35,149 @@
- - - {{ 'device-profile.lwm2m.security' | translate }} - - -
- - {{ 'device-profile.lwm2m.short-id' | translate }} - - - {{ 'device-profile.lwm2m.short-id-required' | translate }} - - - {{ 'device-profile.lwm2m.short-id-range' | translate }} - - - {{ 'device-profile.lwm2m.short-id-pattern' | translate }} - +
+ device-profile.lwm2m.bootstrap-server-legend + + + {{ 'device-profile.lwm2m.server' | translate }} + + +
+ + {{ 'device-profile.lwm2m.short-id' | translate }} + + + {{ 'device-profile.lwm2m.short-id-required' | translate }} + + + {{ 'device-profile.lwm2m.short-id-range' | translate }} + + + {{ 'device-profile.lwm2m.short-id-pattern' | translate }} + + + + {{ 'device-profile.lwm2m.lifetime' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-required' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} + + + + {{ 'device-profile.lwm2m.default-min-period' | translate }} + + + {{ 'device-profile.lwm2m.default-min-period-required' | translate }} + + + {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} + + +
+ + {{ 'device-profile.lwm2m.binding' | translate }} + + + {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} + + - - {{ 'device-profile.lwm2m.lifetime' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-required' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} - + + {{ 'device-profile.lwm2m.notification-storing' | translate }} + +
+
+ + + {{ 'device-profile.lwm2m.security' | translate }} + + + + + + +
+
+ device-profile.lwm2m.lwm2m-server-legend + + + {{ 'device-profile.lwm2m.server' | translate }} + + +
+ + {{ 'device-profile.lwm2m.short-id' | translate }} + + + {{ 'device-profile.lwm2m.short-id-required' | translate }} + + + {{ 'device-profile.lwm2m.short-id-range' | translate }} + + + {{ 'device-profile.lwm2m.short-id-pattern' | translate }} + + + + {{ 'device-profile.lwm2m.lifetime' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-required' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} + + + + {{ 'device-profile.lwm2m.default-min-period' | translate }} + + + {{ 'device-profile.lwm2m.default-min-period-required' | translate }} + + + {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} + + +
+ + {{ 'device-profile.lwm2m.binding' | translate }} + + + {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} + + - - {{ 'device-profile.lwm2m.default-min-period' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-required' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} - - -
- - {{ 'device-profile.lwm2m.binding' | translate }} - - - {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} - - - - - {{ 'device-profile.lwm2m.notification-storing' | translate }} - -
-
- - - {{ 'device-profile.lwm2m.bootstrap-server' | translate }} - - - - - - - - - {{ 'device-profile.lwm2m.lwm2m-server' | translate }} - - - - - - + + {{ 'device-profile.lwm2m.notification-storing' | translate }} + + + + + + {{ 'device-profile.lwm2m.security' | translate }} + + + + + + +
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts index 2845ad75b3..7025415ab8 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts @@ -45,28 +45,30 @@ export const DEFAULT_PAGING_TRANSMISSION_WINDOW = 10000; export enum BingingMode { U = 'U', - UQ = 'UQ', + M = 'M', + H = 'H', T = 'T', - TQ = 'TQ', S = 'S', - SQ = 'SQ', - US = 'US', - TS = 'TS', + N = 'N', + UQ = 'UQ', UQS = 'UQS', - TQS = 'TQS' + TQ = 'TQ', + TQS = 'TQS', + SQ = 'SQ' } export const BingingModeTranslationsMap = new Map( [ [BingingMode.U, 'device-profile.lwm2m.binding-type.u'], + [BingingMode.M, 'device-profile.lwm2m.binding-type.m'], + [BingingMode.H, 'device-profile.lwm2m.binding-type.h'], + [BingingMode.T, 'device-profile.lwm2m.binding-type.t'], + [BingingMode.S, 'device-profile.lwm2m.binding-type.s'], + [BingingMode.N, 'device-profile.lwm2m.binding-type.n'], [BingingMode.UQ, 'device-profile.lwm2m.binding-type.uq'], - [BingingMode.US, 'device-profile.lwm2m.binding-type.us'], [BingingMode.UQS, 'device-profile.lwm2m.binding-type.uqs'], - [BingingMode.T, 'device-profile.lwm2m.binding-type.t'], [BingingMode.TQ, 'device-profile.lwm2m.binding-type.tq'], - [BingingMode.TS, 'device-profile.lwm2m.binding-type.ts'], [BingingMode.TQS, 'device-profile.lwm2m.binding-type.tqs'], - [BingingMode.S, 'device-profile.lwm2m.binding-type.s'], [BingingMode.SQ, 'device-profile.lwm2m.binding-type.sq'] ] ); diff --git a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json index 97bc94b645..0d872dc003 100644 --- a/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json +++ b/ui-ngx/src/assets/locale/locale.constant-cs_CZ.json @@ -1270,21 +1270,7 @@ "default-min-period-pattern": "Minimální interval musí být kladné celé číslo.", "notification-storing": "Ukládání notifikací v případě nedostupnosti", "binding": "Binding", - "binding-type": { - "u": "U: UDP spojení ve standardním režimu", - "uq": "UQ: UDP spojení v queue režimu", - "us": "US: UDP i SMS spojení aktivní, obojí ve standardním režimu", - "uqs": "UQS: UDP i SMS spojení aktivní; UDP v queue režimu, SMS ve standardním režimu", - "t": "T: TCP spojení ve standardním režimu", - "tq": "TQ: TCP spojení v queue režimu", - "ts": "TS: TCP i SMS spojení aktivní, obojí ve standardním režimu", - "tqs": "TQS: TCP i SMS spojení aktivní; TCP v queue režimu, SMS ve standardním režimu", - "s": "S: SMS spojení ve standardním režimu", - "sq": "SQ: SMS spojení v queue režimu" - }, "bootstrap-tab": "Bootstrap", - "bootstrap-server": "Bootstrap server", - "lwm2m-server": "LwM2M server", "server-host": "Host", "server-host-required": "Host je povinný.", "server-port": "Port", diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 5c4333f76c..a46b64384a 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1277,9 +1277,12 @@ "view-attribute": "View attribute", "remove-attribute": "Remove attribute", "mode": "Security config mode", - "security": "Securities", "bootstrap-tab": "Bootstrap", + "bootstrap-server-legend": "Bootstrap Server (ShortId...)", + "lwm2m-server-legend": "LwM2M Server (ShortId...)", + "server": "Server", "short-id": "Short ID", + "short-id-tooltip": "Server ShortID must be equal Security ShortID ", "short-id-required": "Short ID is required.", "short-id-range": "Short ID should be in a range from 1 to 65534.", "short-id-pattern": "Short ID must be a positive integer.", @@ -1287,24 +1290,26 @@ "lifetime-required": "Client registration lifetime is required.", "lifetime-pattern": "Client registration lifetime must be a positive integer.", "default-min-period": "Minimum period between two notifications (s)", + "default-min-period-tooltip": "The default value the LwM2M Client should use for the Minimum Period of an Observation in the absence of this parameter being included in an Observation.", "default-min-period-required": "Minimum period is required.", "default-min-period-pattern": "Minimum period must be a positive integer.", "notification-storing": "Notification storing when disabled or offline", "binding": "Binding", "binding-type": { - "u": "U: UDP connection in standard mode", - "uq": "UQ: UDP connection in queue mode", - "us": "US: both UDP and SMS connections active, both in standard mode", - "uqs": "UQS: both UDP and SMS connections active; UDP in queue mode, SMS in standard mode", - "t": "T: TCP connection in standard mode", - "tq": "TQ: TCP connection in queue mode", - "ts": "TS: both TCP and SMS connections active, both in standard mode", - "tqs": "TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode", - "s": "S: SMS connection in standard mode", - "sq": "SQ: SMS connection in queue mode" + "u": "U: Client is reachable via the UDP binding at any time.", + "m": "M: Client is reachable via the MQTT binding at any time.", + "h": "H: Client is reachable via the HTTP binding at any time.", + "t": "T: Client is reachable via the TCP binding at any time.", + "s": "S: Client is reachable via the SMS binding at any time.", + "n": "N: Client MUST send the response to such a request over the Non-IP binding (is supported since LWM2M 1.1).", + "uq": "UQ: UDP connection in queue mode (is not supported since LWM2M 1.1)", + "uqs": "UQS: both UDP and SMS connections active; UDP in queue mode, SMS in standard mode (is not supported since LWM2M 1.1)", + "tq": "TQ: TCP connection in queue mode (is not supported since LWM2M 1.1)", + "tqs": "TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode (is not supported since LWM2M 1.1)", + "sq": "SQ: SMS connection in queue mode (is not supported since LWM2M 1.1)" }, - "bootstrap-server": "Bootstrap Server", - "lwm2m-server": "LwM2M Server", + "binding-tooltip": "Tis is the list in the\"binding\" resource of the LwM2M server object - /1/x/7.\nIndicates the supported binding modes in the LwM2M Client.\nThis value SHOULD be the same as the value in the “Supported Binding and Modes” resource in the Device Object (/3/0/16).\nWhile multiple transports are supported, only one transport binding can be used during the entire Transport\nSession. As an example, when UDP and SMS are both supported, the LwM2M Client and the LwM2M Server can\nchoose to communicate either over UDP or SMS during the entire Transport Session.", + "security": "Security", "server-host": "Host", "server-host-required": "Host is required.", "server-port": "Port", diff --git a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json index 3bca05e458..432644ae56 100644 --- a/ui-ngx/src/assets/locale/locale.constant-tr_TR.json +++ b/ui-ngx/src/assets/locale/locale.constant-tr_TR.json @@ -1283,18 +1283,6 @@ "default-min-period-pattern": "Minimum süre pozitif bir tam sayı olmalıdır.", "notification-storing": "Devre dışı bırakıldığında veya çevrimdışı olduğunda bildirim depolama", "binding": "Bağlama", - "binding-type": { - "u": "U: UDP connection in standard mode", - "uq": "UQ: UDP connection in queue mode", - "us": "US: both UDP and SMS connections active, both in standard mode", - "uqs": "UQS: both UDP and SMS connections active; UDP in queue mode, SMS in standard mode", - "t": "T: TCP connection in standard mode", - "tq": "TQ: TCP connection in queue mode", - "ts": "TS: both TCP and SMS connections active, both in standard mode", - "tqs": "TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode", - "s": "S: SMS connection in standard mode", - "sq": "SQ: SMS connection in queue mode" - }, "bootstrap-tab": "Bootstrap", "bootstrap-server": "Bootstrap Sunucusu", "lwm2m-server": "LwM2M Sunucusu", From b095922aa8c4e6e6a00414c8c94c3d9e0c383f58 Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Wed, 3 Nov 2021 15:22:15 +0200 Subject: [PATCH 5/9] lwm2m - Biding mode default --- .../profile/device/lwm2m/lwm2m-profile-config.models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts index 7025415ab8..070d0b703d 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts @@ -32,7 +32,7 @@ export const DEFAULT_CLIENT_HOLD_OFF_TIME = 1; export const DEFAULT_LIFE_TIME = 300; export const DEFAULT_MIN_PERIOD = 1; export const DEFAULT_NOTIF_IF_DESIBLED = true; -export const DEFAULT_BINDING = 'UQ'; +export const DEFAULT_BINDING = 'U'; export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0; export const INSTANCES_ID_VALUE_MIN = 0; export const INSTANCES_ID_VALUE_MAX = 65535; From 4ad4b904847e3106e19e0acc23914deed899ce0d Mon Sep 17 00:00:00 2001 From: Sergey Tarnavskiy Date: Mon, 8 Nov 2021 11:31:50 +0200 Subject: [PATCH 6/9] Reafctoring of helping-tooltips for Lwm2m form-configs --- .../app/core/http/device-profile.service.ts | 12 +- ...ce-credentials-lwm2m-server.component.html | 11 +- ...vice-credentials-lwm2m-server.component.ts | 4 + .../device-credentials-lwm2m.component.html | 17 +- .../device-credentials-lwm2m.component.ts | 3 +- .../lwm2m-device-config-server.component.html | 23 +- .../lwm2m-device-config-server.component.ts | 30 ++- ...ile-transport-configuration.component.html | 225 +++++++----------- ...ofile-transport-configuration.component.ts | 2 +- .../lwm2m/lwm2m-profile-config.models.ts | 21 +- .../models/lwm2m-security-config.models.ts | 23 ++ .../assets/locale/locale.constant-en_US.json | 20 +- 12 files changed, 175 insertions(+), 216 deletions(-) diff --git a/ui-ngx/src/app/core/http/device-profile.service.ts b/ui-ngx/src/app/core/http/device-profile.service.ts index 26e68a2e88..1514b262aa 100644 --- a/ui-ngx/src/app/core/http/device-profile.service.ts +++ b/ui-ngx/src/app/core/http/device-profile.service.ts @@ -24,13 +24,13 @@ import { DeviceProfile, DeviceProfileInfo, DeviceTransportType } from '@shared/m import { deepClone, isDefinedAndNotNull, isEmptyStr } from '@core/utils'; import { ObjectLwM2M, - securityConfigMode, ServerSecurityConfig, ServerSecurityConfigInfo } from '@home/components/profile/device/lwm2m/lwm2m-profile-config.models'; import { SortOrder } from '@shared/models/page/sort-order'; import { OtaPackageService } from '@core/http/ota-package.service'; import { map, mergeMap, tap } from 'rxjs/operators'; +import { Lwm2mSecurityType } from '@shared/models/lwm2m-security-config.models'; @Injectable({ providedIn: 'root' @@ -79,23 +79,23 @@ export class DeviceProfileService { } } - public getLwm2mBootstrapSecurityInfoBySecurityType(isBootstrapServer: boolean, securityMode = securityConfigMode.NO_SEC, + public getLwm2mBootstrapSecurityInfoBySecurityType(isBootstrapServer: boolean, securityMode = Lwm2mSecurityType.NO_SEC, config?: RequestConfig): Observable { return this.getLwm2mBootstrapSecurityInfo(isBootstrapServer, config).pipe( map(securityConfig => { const serverSecurityConfigInfo = deepClone(securityConfig); switch (securityMode) { - case securityConfigMode.PSK: + case Lwm2mSecurityType.PSK: serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort; serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost; serverSecurityConfigInfo.serverPublicKey = ''; break; - case securityConfigMode.RPK: - case securityConfigMode.X509: + case Lwm2mSecurityType.RPK: + case Lwm2mSecurityType.X509: serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort; serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost; break; - case securityConfigMode.NO_SEC: + case Lwm2mSecurityType.NO_SEC: serverSecurityConfigInfo.serverPublicKey = ''; break; } diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html index d9f08787b6..9694faa9ca 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.html @@ -27,14 +27,13 @@
{{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }} + help @@ -43,15 +42,13 @@ {{ 'device.lwm2m-security-config.client-secret-key' | translate }} + help diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.ts b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.ts index 96b1e74fb9..9967280a60 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.ts +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m-server.component.ts @@ -26,6 +26,8 @@ import { Validators } from '@angular/forms'; import { + Lwm2mClientSecretKeyTooltipTranslationsMap, + Lwm2mPublicKeyOrIdTooltipTranslationsMap, Lwm2mSecurityType, Lwm2mSecurityTypeTranslationMap, ServerSecurityConfig @@ -57,6 +59,8 @@ export class DeviceCredentialsLwm2mServerComponent implements OnDestroy, Control securityConfigLwM2MType = Lwm2mSecurityType; securityConfigLwM2MTypes = Object.values(Lwm2mSecurityType); lwm2mSecurityTypeTranslationMap = Lwm2mSecurityTypeTranslationMap; + publicKeyOrIdTooltipNamesMap = Lwm2mPublicKeyOrIdTooltipTranslationsMap; + clientSecretKeyTooltipNamesMap = Lwm2mClientSecretKeyTooltipTranslationsMap; private destroy$ = new Subject(); private propagateChange = (v: any) => {}; diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html index 5833e33934..8ffa4ab1e6 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.html @@ -37,9 +37,9 @@ {{ 'device.lwm2m-security-config.identity' | translate }} - + help + {{ 'device.lwm2m-security-config.identity-required' | translate }} @@ -47,15 +47,14 @@ {{ 'device.lwm2m-security-config.client-key' | translate }} + help {{ 'device.lwm2m-security-config.client-key-required' | translate }} @@ -63,12 +62,12 @@ device.lwm2m-security-config.client-public-key + help device.lwm2m-security-config.client-public-key-hint diff --git a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.ts b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.ts index 1645d3317d..10f5124352 100644 --- a/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.ts +++ b/ui-ngx/src/app/modules/home/components/device/device-credentials-lwm2m.component.ts @@ -27,7 +27,7 @@ import { } from '@angular/forms'; import { getDefaultClientSecurityConfig, - getDefaultServerSecurityConfig, + getDefaultServerSecurityConfig, Lwm2mClientKeyTooltipTranslationsMap, Lwm2mSecurityConfigModels, Lwm2mSecurityType, Lwm2mSecurityTypeTranslationMap @@ -60,6 +60,7 @@ export class DeviceCredentialsLwm2mComponent implements ControlValueAccessor, Va securityConfigLwM2MType = Lwm2mSecurityType; securityConfigLwM2MTypes = Object.keys(Lwm2mSecurityType); credentialTypeLwM2MNamesMap = Lwm2mSecurityTypeTranslationMap; + clientKeyTooltipNamesMap = Lwm2mClientKeyTooltipTranslationsMap; private destroy$ = new Subject(); private propagateChange = (v: any) => {}; diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html index b481c9a24a..3fe4e7cda8 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.html @@ -51,8 +51,9 @@
{{ 'device-profile.lwm2m.short-id' | translate }} - + help + {{ 'device-profile.lwm2m.short-id-required' | translate }} @@ -66,9 +67,9 @@ {{ 'device-profile.lwm2m.client-hold-off-time' | translate }} - + help + {{ 'device-profile.lwm2m.client-hold-off-time-required' | translate }} @@ -79,9 +80,9 @@ {{ 'device-profile.lwm2m.account-after-timeout' | translate }} - + help + {{ 'device-profile.lwm2m.account-after-timeout-required' | translate }} @@ -95,16 +96,14 @@ serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509"> {{ 'device-profile.lwm2m.server-public-key' | translate }} + help {{ 'device-profile.lwm2m.server-public-key-required' | translate }} diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts index 93c22d44b1..9492b18114 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts @@ -28,14 +28,17 @@ import { import { DEFAULT_PORT_BOOTSTRAP_NO_SEC, DEFAULT_PORT_SERVER_NO_SEC, - securityConfigMode, - securityConfigModeNames, ServerSecurityConfig } from './lwm2m-profile-config.models'; import { DeviceProfileService } from '@core/http/device-profile.service'; import { Subject } from 'rxjs'; import { mergeMap, takeUntil, tap } from 'rxjs/operators'; import { Observable } from 'rxjs/internal/Observable'; +import { + Lwm2mPublicKeyOrIdTooltipTranslationsMap, + Lwm2mSecurityType, + Lwm2mSecurityTypeTranslationMap +} from '@shared/models/lwm2m-security-config.models'; @Component({ selector: 'tb-profile-lwm2m-device-config-server', @@ -56,15 +59,16 @@ import { Observable } from 'rxjs/internal/Observable'; export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAccessor, Validator, OnDestroy { - private disabled = false; + public disabled = false; private destroy$ = new Subject(); private isDataLoadedIntoCache = false; serverFormGroup: FormGroup; - securityConfigLwM2MType = securityConfigMode; - securityConfigLwM2MTypes = Object.keys(securityConfigMode); - credentialTypeLwM2MNamesMap = securityConfigModeNames; + securityConfigLwM2MType = Lwm2mSecurityType; + securityConfigLwM2MTypes = Object.keys(Lwm2mSecurityType); + credentialTypeLwM2MNamesMap = Lwm2mSecurityTypeTranslationMap; + publicKeyOrIdTooltipNamesMap = Lwm2mPublicKeyOrIdTooltipTranslationsMap; currentSecurityMode = null; @Input() @@ -81,7 +85,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc host: ['', Validators.required], port: [this.isBootstrapServer ? DEFAULT_PORT_BOOTSTRAP_NO_SEC : DEFAULT_PORT_SERVER_NO_SEC, [Validators.required, Validators.min(1), Validators.max(65535), Validators.pattern('[0-9]*')]], - securityMode: [securityConfigMode.NO_SEC], + securityMode: [Lwm2mSecurityType.NO_SEC], serverPublicKey: [''], clientHoldOffTime: ['', [Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]], serverId: ['', [Validators.required, Validators.min(1), Validators.max(65534), Validators.pattern('[0-9]*')]], @@ -136,16 +140,16 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc registerOnTouched(fn: any): void { } - private updateValidate(securityMode: securityConfigMode): void { + private updateValidate(securityMode: Lwm2mSecurityType): void { switch (securityMode) { - case securityConfigMode.NO_SEC: - case securityConfigMode.PSK: + case Lwm2mSecurityType.NO_SEC: + case Lwm2mSecurityType.PSK: this.clearValidators(); break; - case securityConfigMode.RPK: + case Lwm2mSecurityType.RPK: this.setValidators(); break; - case securityConfigMode.X509: + case Lwm2mSecurityType.X509: this.setValidators(); break; } @@ -166,7 +170,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc } } - private getLwm2mBootstrapSecurityInfo(securityMode = securityConfigMode.NO_SEC): Observable { + private getLwm2mBootstrapSecurityInfo(securityMode = Lwm2mSecurityType.NO_SEC): Observable { return this.deviceProfileService.getLwm2mBootstrapSecurityInfoBySecurityType(this.isBootstrapServer, securityMode).pipe( tap(() => this.isDataLoadedIntoCache = true) ); diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html index b58546cf70..a042ba5ea3 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html @@ -33,151 +33,92 @@
-
+
-
- device-profile.lwm2m.bootstrap-server-legend - - - {{ 'device-profile.lwm2m.server' | translate }} - - -
- - {{ 'device-profile.lwm2m.short-id' | translate }} - - - {{ 'device-profile.lwm2m.short-id-required' | translate }} - - - {{ 'device-profile.lwm2m.short-id-range' | translate }} - - - {{ 'device-profile.lwm2m.short-id-pattern' | translate }} - - - - {{ 'device-profile.lwm2m.lifetime' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-required' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} - - - - {{ 'device-profile.lwm2m.default-min-period' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-required' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} - - -
- - {{ 'device-profile.lwm2m.binding' | translate }} - - - {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} - - + + + {{ 'device-profile.lwm2m.server' | translate }} + + +
+ + {{ 'device-profile.lwm2m.short-id' | translate }} + help + + + {{ 'device-profile.lwm2m.short-id-required' | translate }} + + + {{ 'device-profile.lwm2m.short-id-range' | translate }} + + + {{ 'device-profile.lwm2m.short-id-pattern' | translate }} + - - {{ 'device-profile.lwm2m.notification-storing' | translate }} - - - - - - {{ 'device-profile.lwm2m.security' | translate }} - - - - - - -
-
- device-profile.lwm2m.lwm2m-server-legend - - - {{ 'device-profile.lwm2m.server' | translate }} - - -
- - {{ 'device-profile.lwm2m.short-id' | translate }} - - - {{ 'device-profile.lwm2m.short-id-required' | translate }} - - - {{ 'device-profile.lwm2m.short-id-range' | translate }} - - - {{ 'device-profile.lwm2m.short-id-pattern' | translate }} - - - - {{ 'device-profile.lwm2m.lifetime' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-required' | translate }} - - - {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} - - - - {{ 'device-profile.lwm2m.default-min-period' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-required' | translate }} - - - {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} - - -
- - {{ 'device-profile.lwm2m.binding' | translate }} - - - {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} - - + + {{ 'device-profile.lwm2m.lifetime' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-required' | translate }} + + + {{ 'device-profile.lwm2m.lifetime-pattern' | translate }} + - - {{ 'device-profile.lwm2m.notification-storing' | translate }} - -
-
- - - {{ 'device-profile.lwm2m.security' | translate }} - - - - - - -
+ + {{ 'device-profile.lwm2m.default-min-period' | translate }} + help + + + {{ 'device-profile.lwm2m.default-min-period-required' | translate }} + + + {{ 'device-profile.lwm2m.default-min-period-pattern' | translate }} + + +
+ + {{ 'device-profile.lwm2m.binding' | translate }} + help + + + {{ bindingModeTypeNamesMap.get(bindingMode) | translate }} + + + + + {{ 'device-profile.lwm2m.notification-storing' | translate }} + + + + + + {{ 'device-profile.lwm2m.bootstrap-server' | translate }} + + + + + + + + + {{ 'device-profile.lwm2m.lwm2m-server' | translate }} + + + + + +
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts index 2495a16eff..792aa3c315 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts @@ -79,8 +79,8 @@ import { takeUntil } from 'rxjs/operators'; }) export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validator, OnDestroy { + public disabled = false; private requiredValue: boolean; - private disabled = false; private destroy$ = new Subject(); bindingModeTypes = Object.values(BingingMode); diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts index 070d0b703d..e95d1d22d2 100644 --- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts +++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts @@ -15,6 +15,7 @@ /// import { ValidatorFn, Validators } from '@angular/forms'; +import { Lwm2mSecurityType } from '@shared/models/lwm2m-security-config.models'; export const PAGE_SIZE_LIMIT = 50; export const INSTANCES = 'instances'; @@ -95,22 +96,6 @@ export const AttributeNameTranslationMap = new Map( ] ); -export enum securityConfigMode { - PSK = 'PSK', - RPK = 'RPK', - X509 = 'X509', - NO_SEC = 'NO_SEC' -} - -export const securityConfigModeNames = new Map( - [ - [securityConfigMode.PSK, 'Pre-Shared Key'], - [securityConfigMode.RPK, 'Raw Public Key'], - [securityConfigMode.X509, 'X.509 Certificate'], - [securityConfigMode.NO_SEC, 'No Security'] - ] -); - export enum PowerMode { PSM = 'PSM', DRX = 'DRX', @@ -136,7 +121,7 @@ export interface BootstrapServersSecurityConfig { export interface ServerSecurityConfig { host?: string; port?: number; - securityMode: securityConfigMode; + securityMode: Lwm2mSecurityType; serverPublicKey?: string; clientHoldOffTime?: number; serverId?: number; @@ -198,7 +183,7 @@ export function getDefaultBootstrapServerSecurityConfig(): ServerSecurityConfig clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME, host: DEFAULT_LOCAL_HOST_NAME, port: DEFAULT_PORT_BOOTSTRAP_NO_SEC, - securityMode: securityConfigMode.NO_SEC, + securityMode: Lwm2mSecurityType.NO_SEC, serverId: DEFAULT_ID_BOOTSTRAP, serverPublicKey: '' }; diff --git a/ui-ngx/src/app/shared/models/lwm2m-security-config.models.ts b/ui-ngx/src/app/shared/models/lwm2m-security-config.models.ts index d3b4171b80..024433b0c7 100644 --- a/ui-ngx/src/app/shared/models/lwm2m-security-config.models.ts +++ b/ui-ngx/src/app/shared/models/lwm2m-security-config.models.ts @@ -30,6 +30,29 @@ export const Lwm2mSecurityTypeTranslationMap = new Map( + [ + [Lwm2mSecurityType.PSK, 'device.lwm2m-security-config.client-publicKey-or-id-tooltip-psk'], + [Lwm2mSecurityType.RPK, 'device.lwm2m-security-config.client-publicKey-or-id-tooltip-rpk'], + [Lwm2mSecurityType.X509, 'device.lwm2m-security-config.client-publicKey-or-id-tooltip-x509'] + ] +); + +export const Lwm2mClientSecretKeyTooltipTranslationsMap = new Map( + [ + [Lwm2mSecurityType.PSK, 'device.lwm2m-security-config.client-secret-key-tooltip-psk'], + [Lwm2mSecurityType.RPK, 'device.lwm2m-security-config.client-secret-key-tooltip-prk'], + [Lwm2mSecurityType.X509, 'device.lwm2m-security-config.client-secret-key-tooltip-x509'] + ] +); + +export const Lwm2mClientKeyTooltipTranslationsMap = new Map( + [ + [Lwm2mSecurityType.PSK, 'device.lwm2m-security-config.client-secret-key-tooltip-psk'], + [Lwm2mSecurityType.RPK, 'device.lwm2m-security-config.client-secret-key-tooltip-prk'] + ] +); + export interface ClientSecurityConfig { securityConfigClientMode: Lwm2mSecurityType; endpoint: string; diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index a46b64384a..2080a44d45 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -966,12 +966,13 @@ "identity-tooltip": "The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standard [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.", "client-key": "Client Key", "client-key-required": "Client Key is required.", - "client-key-tooltip": "{ count, plural, 1 {RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!} other {PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!} }", + "client-key-tooltip-prk": "RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!", + "client-key-tooltip-psk": "PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!", "endpoint": "Endpoint Client Name", "endpoint-required": "Endpoint Client Name is required.", "client-public-key": "Client public key", "client-public-key-hint": "If client public key is empty, the trusted certificate will be used", - "client-public-key-tooltip": "{ count, plural, 1 {X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format!} other {} }", + "client-public-key-tooltip": "X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format!", "mode": "Security config mode", "client-tab": "Client Security Config", "client-certificate": "Client certificate", @@ -980,10 +981,14 @@ "lwm2m-server": "LwM2M Server", "client-publicKey-or-id": "Client Public Key or Id", "client-publicKey-or-id-required": "Client Public Key or Id is required.", - "client-publicKey-or-id-tooltip": "{ count, plural, 0 {The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standard [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.} 1 {RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!} other {X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format!} }", + "client-publicKey-or-id-tooltip-psk": "The PSK identifier is an arbitrary PSK identifier up to 128 bytes, as described in the standard [RFC7925].\nThe PSK identifier MUST first be converted to a character string and then encoded into octets using UTF-8.", + "client-publicKey-or-id-tooltip-rpk": "RPK public key or id must be in the standard [RFC7250] and encoded to Base64 format!", + "client-publicKey-or-id-tooltip-x509": "X509 public key must be in DER-encoded X509v3 format and support exclusively EC algorithm and then encoded to Base64 format", "client-secret-key": "Client Secret Key", "client-secret-key-required": "Client Secret Key is required.", - "client-secret-key-tooltip": "{ count, plural, 0 {PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!} 1 {RPK secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!} other {X509 secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!} }" + "client-secret-key-tooltip-psk": "PSK key must be in the standard [RFC4279] and HexDec format: 32, 64, 128 characters!", + "client-secret-key-tooltip-prk": "RPK secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!", + "client-secret-key-tooltip-x509": "X509 secret key must be in PKCS_8 format (DER encoding, standard [RFC5958]) and then encoded to Base64 format!" }, "client-id": "Client ID", "client-id-pattern": "Contains invalid character.", @@ -1289,7 +1294,7 @@ "lifetime": "Client registration lifetime", "lifetime-required": "Client registration lifetime is required.", "lifetime-pattern": "Client registration lifetime must be a positive integer.", - "default-min-period": "Minimum period between two notifications (s)", + "default-min-period": "Min period between two notifications (s)", "default-min-period-tooltip": "The default value the LwM2M Client should use for the Minimum Period of an Observation in the absence of this parameter being included in an Observation.", "default-min-period-required": "Minimum period is required.", "default-min-period-pattern": "Minimum period must be a positive integer.", @@ -1308,8 +1313,9 @@ "tqs": "TQS: both TCP and SMS connections active; TCP in queue mode, SMS in standard mode (is not supported since LWM2M 1.1)", "sq": "SQ: SMS connection in queue mode (is not supported since LWM2M 1.1)" }, - "binding-tooltip": "Tis is the list in the\"binding\" resource of the LwM2M server object - /1/x/7.\nIndicates the supported binding modes in the LwM2M Client.\nThis value SHOULD be the same as the value in the “Supported Binding and Modes” resource in the Device Object (/3/0/16).\nWhile multiple transports are supported, only one transport binding can be used during the entire Transport\nSession. As an example, when UDP and SMS are both supported, the LwM2M Client and the LwM2M Server can\nchoose to communicate either over UDP or SMS during the entire Transport Session.", - "security": "Security", + "binding-tooltip": "Tis is the list in the\"binding\" resource of the LwM2M server object - /1/x/7.\nIndicates the supported binding modes in the LwM2M Client.\nThis value SHOULD be the same as the value in the “Supported Binding and Modes” resource in the Device Object (/3/0/16).\nWhile multiple transports are supported, only one transport binding can be used during the entire Transport Session.\nAs an example, when UDP and SMS are both supported, the LwM2M Client and the LwM2M Server can choose to communicate either over UDP or SMS during the entire Transport Session.", + "bootstrap-server": "Bootstrap Server", + "lwm2m-server": "LwM2M Server", "server-host": "Host", "server-host-required": "Host is required.", "server-port": "Port", From e1442c38bb18e34d76b157d27763b9b77fc88703 Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Mon, 8 Nov 2021 21:56:26 +0200 Subject: [PATCH 7/9] lwm2m - profile&device bootstrap M4 --- .../server/controller/Lwm2mController.java | 9 ++++----- .../server/service/lwm2m/LwM2MService.java | 2 +- .../server/service/lwm2m/LwM2MServiceImpl.java | 12 ++++++++---- .../lwm2m/bootstrap/LwM2MBootstrapServerConfig.java | 3 +++ .../LwM2MBootstrapServersConfiguration.java | 3 +++ .../common/data/lwm2m/ServerSecurityConfig.java | 6 +++++- .../lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java | 11 +++++++++++ 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java b/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java index 7a772a69cc..72f91e11eb 100644 --- a/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java +++ b/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java @@ -37,6 +37,7 @@ import org.thingsboard.server.service.lwm2m.LwM2MService; import org.thingsboard.server.service.lwm2m.LwM2MServiceImpl; import org.thingsboard.server.service.security.permission.Resource; +import java.util.List; import java.util.Map; import static org.thingsboard.server.controller.ControllerConstants.IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION; @@ -61,13 +62,11 @@ public class Lwm2mController extends BaseController { TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, produces = "application/json") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") - @RequestMapping(value = "/lwm2m/deviceProfile/bootstrap/{isBootstrapServer}", method = RequestMethod.GET) + @RequestMapping(value = "/lwm2m/deviceProfile/bootstrap", method = RequestMethod.GET) @ResponseBody - public ServerSecurityConfig getLwm2mBootstrapSecurityInfo( - @ApiParam(value = IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION) - @PathVariable(IS_BOOTSTRAP_SERVER) boolean bootstrapServer) throws ThingsboardException { + public ServerSecurityConfig [] getLwm2mBootstrapSecurityInfo() throws ThingsboardException { try { - return lwM2MService.getServerSecurityInfo(bootstrapServer); + return lwM2MService.getServerSecurityInfo(); } catch (Exception e) { throw handleException(e); } diff --git a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java index 7d1a69d270..2dc2827317 100644 --- a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java +++ b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java @@ -19,6 +19,6 @@ import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; public interface LwM2MService { - ServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer); + ServerSecurityConfig [] getServerSecurityInfo(); } diff --git a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java index c846c60d14..46a56909cf 100644 --- a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java +++ b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java @@ -26,6 +26,8 @@ import org.thingsboard.server.transport.lwm2m.config.LwM2MSecureServerConfig; import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportBootstrapConfig; import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig; +import java.util.List; + @Slf4j @Service @RequiredArgsConstructor @@ -36,10 +38,12 @@ public class LwM2MServiceImpl implements LwM2MService { private final LwM2MTransportBootstrapConfig bootstrapConfig; @Override - public ServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer) { - ServerSecurityConfig result = getServerSecurityConfig(bootstrapServer ? bootstrapConfig : serverConfig); - result.setBootstrapServerIs(bootstrapServer); - return result; + public ServerSecurityConfig [] getServerSecurityInfo() { + ServerSecurityConfig bootstrapServer = getServerSecurityConfig(bootstrapConfig); + bootstrapServer.setBootstrapServerIs(true); + ServerSecurityConfig lwm2mServer = getServerSecurityConfig(serverConfig); + lwm2mServer.setBootstrapServerIs(false); + return new ServerSecurityConfig[] {bootstrapServer, lwm2mServer}; } private ServerSecurityConfig getServerSecurityConfig(LwM2MSecureServerConfig serverConfig) { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java index f27f01978f..35adce1187 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java @@ -19,6 +19,9 @@ import lombok.Data; @Data public class LwM2MBootstrapServerConfig { + + protected Integer shortServerId = 123; + private Integer shortId = 123; private Integer lifetime = 300; private Integer defaultMinPeriod = 1; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java index 6347ecc06c..fd3cfad5a5 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java @@ -17,10 +17,13 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import lombok.Data; +import java.util.List; + @Data public class LwM2MBootstrapServersConfiguration { //TODO + List serversConfiguration; // List LwM2MBootstrapServersConfigurations; // LwM2MBootstrapServersConfiguration: Integer shortId, LwM2MBootstrapServerConfig serverConfig; LwM2MBootstrapServerCredential serverSecurity. diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java index 83b56a2661..a98f9c52ee 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java @@ -18,10 +18,14 @@ package org.thingsboard.server.common.data.lwm2m; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerConfig; @ApiModel @Data -public class ServerSecurityConfig { +public class ServerSecurityConfig extends LwM2MBootstrapServerConfig { + + protected Integer shortServerId = 123; + @ApiModelProperty(position = 1, value = "Is Bootstrap Server or Lwm2m Server", example = "true or false", readOnly = true) protected boolean bootstrapServerIs = true; @ApiModelProperty(position = 2, value = "Host for 'No Security' mode", example = "0.0.0.0", readOnly = true) diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java index f2ba39dcfa..29024d8f8f 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/bootstrap/secure/LwM2MBootstrapConfig.java @@ -23,12 +23,18 @@ import org.eclipse.leshan.core.SecurityMode; import org.eclipse.leshan.core.request.BindingMode; import org.eclipse.leshan.core.util.Hex; import org.eclipse.leshan.server.bootstrap.BootstrapConfig; +import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MBootstrapClientCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential; import java.io.Serializable; import java.nio.charset.StandardCharsets; +import java.util.List; @Data public class LwM2MBootstrapConfig implements Serializable { + + List serversConfiguration; + LwM2MBootstrapClientCredential bootstrapClientCredential; /* interface BootstrapSecurityConfig servers: BootstrapServersSecurityConfig, @@ -68,6 +74,11 @@ public class LwM2MBootstrapConfig implements Serializable { @Setter private LwM2MServerBootstrap lwm2mServer; + public LwM2MBootstrapConfig(List serversConfiguration, LwM2MBootstrapClientCredential bootstrapClientCredential) { + this.serversConfiguration = serversConfiguration; + this.bootstrapClientCredential = bootstrapClientCredential; + } + @JsonIgnore public BootstrapConfig getLwM2MBootstrapConfig() { BootstrapConfig configBs = new BootstrapConfig(); From 0ac80664e410ee6d8a8dd0f18bff0517ce5740ab Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Tue, 9 Nov 2021 12:35:05 +0200 Subject: [PATCH 8/9] lwm2m - profile bootstrap config --- .../server/controller/Lwm2mController.java | 21 +++---- .../server/service/lwm2m/LwM2MService.java | 4 +- .../service/lwm2m/LwM2MServiceImpl.java | 20 +++--- .../dao/device/DeviceCredentialsService.java | 2 - ...tLwM2MBootstrapLwM2MServerCredential.java} | 3 +- .../bootstrap/LwM2MBootstrapServerConfig.java | 30 --------- .../LwM2MBootstrapServerCredential.java | 8 +-- .../LwM2MBootstrapServersConfiguration.java | 9 +-- .../bootstrap/LwM2MServerSecurityConfig.java | 63 +++++++++++++++++++ ...cLwM2MBootstrapLwM2MServerCredential.java} | 2 +- ...KLwM2MBootstrapLwM2MServerCredential.java} | 2 +- ...KLwM2MBootstrapLwM2MServerCredential.java} | 2 +- ...9LwM2MBootstrapLwM2MServerCredential.java} | 2 +- .../data/lwm2m/ServerSecurityConfig.java | 48 -------------- .../dao/device/DeviceProfileServiceImpl.java | 8 +-- 15 files changed, 97 insertions(+), 127 deletions(-) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{AbstractLwM2MBootstrapServerCredential.java => AbstractLwM2MBootstrapLwM2MServerCredential.java} (84%) delete mode 100644 common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java create mode 100644 common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MServerSecurityConfig.java rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{NoSecLwM2MBootstrapServerCredential.java => NoSecLwM2MBootstrapLwM2MServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{PSKLwM2MBootstrapServerCredential.java => PSKLwM2MBootstrapLwM2MServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{RPKLwM2MBootstrapServerCredential.java => RPKLwM2MBootstrapLwM2MServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{X509LwM2MBootstrapServerCredential.java => X509LwM2MBootstrapLwM2MServerCredential.java} (89%) delete mode 100644 common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java diff --git a/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java b/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java index 72f91e11eb..86ef420192 100644 --- a/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java +++ b/application/src/main/java/org/thingsboard/server/controller/Lwm2mController.java @@ -30,14 +30,11 @@ import org.springframework.web.bind.annotation.RestController; import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.SaveDeviceWithCredentialsRequest; import org.thingsboard.server.common.data.exception.ThingsboardException; -import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig; import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.queue.util.TbCoreComponent; import org.thingsboard.server.service.lwm2m.LwM2MService; -import org.thingsboard.server.service.lwm2m.LwM2MServiceImpl; -import org.thingsboard.server.service.security.permission.Resource; -import java.util.List; import java.util.Map; import static org.thingsboard.server.controller.ControllerConstants.IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION; @@ -62,14 +59,16 @@ public class Lwm2mController extends BaseController { TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, produces = "application/json") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") - @RequestMapping(value = "/lwm2m/deviceProfile/bootstrap", method = RequestMethod.GET) + @RequestMapping(value = "/lwm2m/deviceProfile/bootstrap/{isBootstrapServer}", method = RequestMethod.GET) @ResponseBody - public ServerSecurityConfig [] getLwm2mBootstrapSecurityInfo() throws ThingsboardException { - try { - return lwM2MService.getServerSecurityInfo(); - } catch (Exception e) { - throw handleException(e); - } + public LwM2MServerSecurityConfig getLwm2mBootstrapSecurityInfo( + @ApiParam(value = IS_BOOTSTRAP_SERVER_PARAM_DESCRIPTION) + @PathVariable(IS_BOOTSTRAP_SERVER) boolean bootstrapServer) throws ThingsboardException { + try { + return lwM2MService.getServerSecurityInfo(bootstrapServer); + } catch (Exception e) { + throw handleException(e); + } } @ApiOperation(hidden = true, value = "Save device with credentials (Deprecated)") diff --git a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java index 2dc2827317..e63f66f0bf 100644 --- a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java +++ b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MService.java @@ -15,10 +15,10 @@ */ package org.thingsboard.server.service.lwm2m; -import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig; public interface LwM2MService { - ServerSecurityConfig [] getServerSecurityInfo(); + LwM2MServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer); } diff --git a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java index 46a56909cf..0ba57cbc00 100644 --- a/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java +++ b/application/src/main/java/org/thingsboard/server/service/lwm2m/LwM2MServiceImpl.java @@ -20,14 +20,12 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.binary.Base64; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Service; -import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MServerSecurityConfig; import org.thingsboard.server.common.transport.config.ssl.SslCredentials; import org.thingsboard.server.transport.lwm2m.config.LwM2MSecureServerConfig; import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportBootstrapConfig; import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig; -import java.util.List; - @Slf4j @Service @RequiredArgsConstructor @@ -38,17 +36,15 @@ public class LwM2MServiceImpl implements LwM2MService { private final LwM2MTransportBootstrapConfig bootstrapConfig; @Override - public ServerSecurityConfig [] getServerSecurityInfo() { - ServerSecurityConfig bootstrapServer = getServerSecurityConfig(bootstrapConfig); - bootstrapServer.setBootstrapServerIs(true); - ServerSecurityConfig lwm2mServer = getServerSecurityConfig(serverConfig); - lwm2mServer.setBootstrapServerIs(false); - return new ServerSecurityConfig[] {bootstrapServer, lwm2mServer}; + public LwM2MServerSecurityConfig getServerSecurityInfo(boolean bootstrapServer) { + LwM2MServerSecurityConfig result = getServerSecurityConfig(bootstrapServer ? bootstrapConfig : serverConfig); + result.setBootstrapServerIs(bootstrapServer); + return result; } - private ServerSecurityConfig getServerSecurityConfig(LwM2MSecureServerConfig serverConfig) { - ServerSecurityConfig bsServ = new ServerSecurityConfig(); - bsServ.setServerId(serverConfig.getId()); + private LwM2MServerSecurityConfig getServerSecurityConfig(LwM2MSecureServerConfig serverConfig) { + LwM2MServerSecurityConfig bsServ = new LwM2MServerSecurityConfig(); + bsServ.setShortServerId(serverConfig.getId()); bsServ.setHost(serverConfig.getHost()); bsServ.setPort(serverConfig.getPort()); bsServ.setSecurityHost(serverConfig.getSecureHost()); diff --git a/common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsService.java b/common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsService.java index a57d39776f..01d1baebb3 100644 --- a/common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsService.java +++ b/common/dao-api/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsService.java @@ -15,10 +15,8 @@ */ package org.thingsboard.server.dao.device; -import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTransportConfiguration; import org.thingsboard.server.common.data.id.DeviceId; import org.thingsboard.server.common.data.id.TenantId; -import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; import org.thingsboard.server.common.data.security.DeviceCredentials; public interface DeviceCredentialsService { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java similarity index 84% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java index 87eeb3a1e1..c92a2ed0eb 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java @@ -20,11 +20,10 @@ import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; import org.apache.commons.codec.binary.Base64; -import org.thingsboard.server.common.data.lwm2m.ServerSecurityConfig; @Getter @Setter -public abstract class AbstractLwM2MBootstrapServerCredential extends ServerSecurityConfig implements LwM2MBootstrapServerCredential { +public abstract class AbstractLwM2MBootstrapLwM2MServerCredential extends LwM2MServerSecurityConfig implements LwM2MBootstrapServerCredential { @JsonIgnore public byte[] getDecodedCServerPublicKey() { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java deleted file mode 100644 index 35adce1187..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright © 2016-2021 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; - -import lombok.Data; - -@Data -public class LwM2MBootstrapServerConfig { - - protected Integer shortServerId = 123; - - private Integer shortId = 123; - private Integer lifetime = 300; - private Integer defaultMinPeriod = 1; - private boolean notifIfDisabled = true; - private String binding = "U"; -} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java index b22e80d81f..a8967c0674 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java @@ -25,10 +25,10 @@ import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurity use = JsonTypeInfo.Id.NAME, property = "securityMode") @JsonSubTypes({ - @JsonSubTypes.Type(value = NoSecLwM2MBootstrapServerCredential.class, name = "NO_SEC"), - @JsonSubTypes.Type(value = PSKLwM2MBootstrapServerCredential.class, name = "PSK"), - @JsonSubTypes.Type(value = RPKLwM2MBootstrapServerCredential.class, name = "RPK"), - @JsonSubTypes.Type(value = X509LwM2MBootstrapServerCredential.class, name = "X509") + @JsonSubTypes.Type(value = NoSecLwM2MBootstrapLwM2MServerCredential.class, name = "NO_SEC"), + @JsonSubTypes.Type(value = PSKLwM2MBootstrapLwM2MServerCredential.class, name = "PSK"), + @JsonSubTypes.Type(value = RPKLwM2MBootstrapLwM2MServerCredential.class, name = "RPK"), + @JsonSubTypes.Type(value = X509LwM2MBootstrapLwM2MServerCredential.class, name = "X509") }) @JsonIgnoreProperties(ignoreUnknown = true) public interface LwM2MBootstrapServerCredential { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java index fd3cfad5a5..15d573b50e 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServersConfiguration.java @@ -22,13 +22,6 @@ import java.util.List; @Data public class LwM2MBootstrapServersConfiguration { - //TODO - List serversConfiguration; - // List LwM2MBootstrapServersConfigurations; - // LwM2MBootstrapServersConfiguration: Integer shortId, LwM2MBootstrapServerConfig serverConfig; LwM2MBootstrapServerCredential serverSecurity. - - private LwM2MBootstrapServerConfig servers; - private LwM2MBootstrapServerCredential lwm2mServer; - private LwM2MBootstrapServerCredential bootstrapServer; + List serverConfiguration; } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MServerSecurityConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MServerSecurityConfig.java new file mode 100644 index 0000000000..7a43bd60ca --- /dev/null +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MServerSecurityConfig.java @@ -0,0 +1,63 @@ +/** + * Copyright © 2016-2021 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel +@Data +public class LwM2MServerSecurityConfig { + + @ApiModelProperty(position = 1, value = "Server short Id. Used as link to associate server Object Instance.\nThis identifier uniquely identifies each LwM2M Server configured for the LwM2M Client.\n" + + "This Resource MUST be set when the Bootstrap-Server Resource has a value of 'false'. \n" + + "The values ID:0 and ID:65535 values MUST NOT be used for identifying the LwM2M Server.", example = "123", readOnly = true) + protected Integer shortServerId = 123; + /** Security -> ObjectId = 0 'LWM2M Security' */ + @ApiModelProperty(position = 2, value = "Is Bootstrap Server or Lwm2m Server", example = "true or false", readOnly = true) + protected boolean bootstrapServerIs = false; + @ApiModelProperty(position = 3, value = "Host for 'No Security' mode", example = "0.0.0.0", readOnly = true) + protected String host; + @ApiModelProperty(position = 4, value = "Port for Lwm2m Server: 'No Security' mode: Lwm2m Server or Bootstrap Server", example = "'5685' or '5687'", readOnly = true) + protected Integer port; + @ApiModelProperty(position = 5, value = "Host for 'Security' mode (DTLS)", example = "0.0.0.0", readOnly = true) + protected String securityHost; + @ApiModelProperty(position = 6, value = "Port for 'Security' mode (DTLS): Lwm2m Server or Bootstrap Server", example = "5686 or 5688", readOnly = true) + protected Integer securityPort; + @ApiModelProperty(position = 7, value = "Client Hold Off Time. The number of seconds to wait before initiating a Client Initiated Bootstrap once the LwM2M Client has determined it should initiate this bootstrap mode. (This information is relevant for use with a Bootstrap-Server only.)", example = "1", readOnly = true) + protected Integer clientHoldOffTime = 1; + @ApiModelProperty(position = 8, value = "Server Public Key for 'Security' mode (DTLS): RPK or X509. Format: base64 encoded", example = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAZ0pSaGKHk/GrDaUDnQZpeEdGwX7m3Ws+U/kiVat\n" + + "+44sgk3c8g0LotfMpLlZJPhPwJ6ipXV+O1r7IZUjBs3LNA==", readOnly = true) + protected String serverPublicKey; + @ApiModelProperty(position = 9, value = "Bootstrap Server Account Timeout (If the value is set to 0, or if this resource is not instantiated, the Bootstrap-Server Account lifetime is infinite.)", example = "0", readOnly = true) + Integer bootstrapServerAccountTimeout = 0; + + /** Config -> ObjectId = 1 'LwM2M Server' */ + @ApiModelProperty(position = 10, value = "Specify the lifetime of the registration in seconds.", example = "300", readOnly = true) + private Integer lifetime = 300; + @ApiModelProperty(position = 11, value = "The default value the LwM2M Client should use for the Minimum Period of an Observation in the absence of this parameter being included in an Observation.\n" + + "If this Resource doesn’t exist, the default value is 0.", example = "1", readOnly = true) + private Integer defaultMinPeriod = 1; + /** ResourceID=6 'Notification Storing When Disabled or Offline' */ + @ApiModelProperty(position = 12, value = "If true, the LwM2M Client stores “Notify” operations to the LwM2M Server while the LwM2M Server account is disabled or the LwM2M Client is offline. After the LwM2M Server account is enabled or the LwM2M Client is online, the LwM2M Client reports the stored “Notify” operations to the Server.\n" + + "If false, the LwM2M Client discards all the “Notify” operations or temporarily disables the Observe function while the LwM2M Server is disabled or the LwM2M Client is offline.\n" + + "The default value is true.", example = "true", readOnly = true) + private boolean notifIfDisabled = true; + @ApiModelProperty(position = 14, value = "This Resource defines the transport binding configured for the LwM2M Client.\n" + + "If the LwM2M Client supports the binding specified in this Resource, the LwM2M Client MUST use that transport for the Current Binding Mode.", example = "U", readOnly = true) + private String binding = "U"; +} diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java index 7730c79ee9..8973232b9a 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class NoSecLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { +public class NoSecLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.NO_SEC; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java index 30f7f8c472..9adf566eb0 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class PSKLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { +public class PSKLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.PSK; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java index c529820709..bf595a394b 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class RPKLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { +public class RPKLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.RPK; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java index e95bf7742d..1c2d83ba8e 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class X509LwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { +public class X509LwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.X509; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java b/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java deleted file mode 100644 index a98f9c52ee..0000000000 --- a/common/data/src/main/java/org/thingsboard/server/common/data/lwm2m/ServerSecurityConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright © 2016-2021 The Thingsboard Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.thingsboard.server.common.data.lwm2m; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerConfig; - -@ApiModel -@Data -public class ServerSecurityConfig extends LwM2MBootstrapServerConfig { - - protected Integer shortServerId = 123; - - @ApiModelProperty(position = 1, value = "Is Bootstrap Server or Lwm2m Server", example = "true or false", readOnly = true) - protected boolean bootstrapServerIs = true; - @ApiModelProperty(position = 2, value = "Host for 'No Security' mode", example = "0.0.0.0", readOnly = true) - protected String host; - @ApiModelProperty(position = 3, value = "Port for Lwm2m Server: 'No Security' mode: Lwm2m Server or Bootstrap Server", example = "'5685' or '5687'", readOnly = true) - protected Integer port; - @ApiModelProperty(position = 4, value = "Host for 'Security' mode (DTLS)", example = "0.0.0.0", readOnly = true) - protected String securityHost; - @ApiModelProperty(position = 5, value = "Port for 'Security' mode (DTLS): Lwm2m Server or Bootstrap Server", example = "5686 or 5688", readOnly = true) - protected Integer securityPort; - @ApiModelProperty(position = 6, value = "Server short Id", example = "111", readOnly = true) - protected Integer serverId = 111; - @ApiModelProperty(position = 7, value = "Client Hold Off Time. The number of seconds to wait before initiating a Client Initiated Bootstrap once the LwM2M Client has determined it should initiate this bootstrap mode. (This information is relevant for use with a Bootstrap-Server only.)", example = "1", readOnly = true) - protected Integer clientHoldOffTime = 1; - @ApiModelProperty(position = 8, value = "Server Public Key for 'Security' mode (DTLS): RPK or X509. Format: base64 encoded", example = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAZ0pSaGKHk/GrDaUDnQZpeEdGwX7m3Ws+U/kiVat\n" + - "+44sgk3c8g0LotfMpLlZJPhPwJ6ipXV+O1r7IZUjBs3LNA==", readOnly = true) - protected String serverPublicKey; - @ApiModelProperty(position = 9, value = "Bootstrap Server Account Timeout (If the value is set to 0, or if this resource is not instantiated, the Bootstrap-Server Account lifetime is infinite.)", example = "0", readOnly = true) - Integer bootstrapServerAccountTimeout = 0; -} diff --git a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java index 3430e5774e..6552bcf1f8 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java @@ -60,9 +60,9 @@ import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTrans import org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration; import org.thingsboard.server.common.data.device.profile.ProtoTransportPayloadConfiguration; import org.thingsboard.server.common.data.device.profile.TransportPayloadTypeConfiguration; -import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapLwM2MServerCredential; import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential; -import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapLwM2MServerCredential; import org.thingsboard.server.common.data.ota.OtaPackageType; import org.thingsboard.server.common.data.id.DeviceProfileId; import org.thingsboard.server.common.data.id.TenantId; @@ -710,7 +710,7 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D case PSK: break; case RPK: - RPKLwM2MBootstrapServerCredential rpkServerCredentials = (RPKLwM2MBootstrapServerCredential) bootstrapServerConfig; + RPKLwM2MBootstrapLwM2MServerCredential rpkServerCredentials = (RPKLwM2MBootstrapLwM2MServerCredential) bootstrapServerConfig; if (StringUtils.isEmpty(rpkServerCredentials.getServerPublicKey())) { throw new DeviceCredentialsValidationException(server + " RPK public key must be specified!"); } @@ -723,7 +723,7 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D } break; case X509: - X509LwM2MBootstrapServerCredential x509ServerCredentials = (X509LwM2MBootstrapServerCredential) bootstrapServerConfig; + X509LwM2MBootstrapLwM2MServerCredential x509ServerCredentials = (X509LwM2MBootstrapLwM2MServerCredential) bootstrapServerConfig; if (StringUtils.isEmpty(x509ServerCredentials.getServerPublicKey())) { throw new DeviceCredentialsValidationException(server + " X509 public key must be specified!"); } From de71dd24b8ec41c6bf62bbf4f15d06939060e742 Mon Sep 17 00:00:00 2001 From: nickAS21 Date: Tue, 9 Nov 2021 13:12:21 +0200 Subject: [PATCH 9/9] lwm2m - rename file --- ...bstractLwM2MBootstrapServerCredential.java} | 2 +- .../LwM2MBootstrapServerCredential.java | 8 ++++---- ...> NoSecLwM2MBootstrapServerCredential.java} | 2 +- ... => PSKLwM2MBootstrapServerCredential.java} | 2 +- ... => RPKLwM2MBootstrapServerCredential.java} | 2 +- ...=> X509LwM2MBootstrapServerCredential.java} | 2 +- .../dao/device/DeviceProfileServiceImpl.java | 18 +++++++++++------- 7 files changed, 20 insertions(+), 16 deletions(-) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{AbstractLwM2MBootstrapLwM2MServerCredential.java => AbstractLwM2MBootstrapServerCredential.java} (88%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{NoSecLwM2MBootstrapLwM2MServerCredential.java => NoSecLwM2MBootstrapServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{PSKLwM2MBootstrapLwM2MServerCredential.java => PSKLwM2MBootstrapServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{RPKLwM2MBootstrapLwM2MServerCredential.java => RPKLwM2MBootstrapServerCredential.java} (89%) rename common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/{X509LwM2MBootstrapLwM2MServerCredential.java => X509LwM2MBootstrapServerCredential.java} (89%) diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java similarity index 88% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java index c92a2ed0eb..ed0330c60b 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapLwM2MServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/AbstractLwM2MBootstrapServerCredential.java @@ -23,7 +23,7 @@ import org.apache.commons.codec.binary.Base64; @Getter @Setter -public abstract class AbstractLwM2MBootstrapLwM2MServerCredential extends LwM2MServerSecurityConfig implements LwM2MBootstrapServerCredential { +public abstract class AbstractLwM2MBootstrapServerCredential extends LwM2MServerSecurityConfig implements LwM2MBootstrapServerCredential { @JsonIgnore public byte[] getDecodedCServerPublicKey() { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java index a8967c0674..b22e80d81f 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/LwM2MBootstrapServerCredential.java @@ -25,10 +25,10 @@ import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurity use = JsonTypeInfo.Id.NAME, property = "securityMode") @JsonSubTypes({ - @JsonSubTypes.Type(value = NoSecLwM2MBootstrapLwM2MServerCredential.class, name = "NO_SEC"), - @JsonSubTypes.Type(value = PSKLwM2MBootstrapLwM2MServerCredential.class, name = "PSK"), - @JsonSubTypes.Type(value = RPKLwM2MBootstrapLwM2MServerCredential.class, name = "RPK"), - @JsonSubTypes.Type(value = X509LwM2MBootstrapLwM2MServerCredential.class, name = "X509") + @JsonSubTypes.Type(value = NoSecLwM2MBootstrapServerCredential.class, name = "NO_SEC"), + @JsonSubTypes.Type(value = PSKLwM2MBootstrapServerCredential.class, name = "PSK"), + @JsonSubTypes.Type(value = RPKLwM2MBootstrapServerCredential.class, name = "RPK"), + @JsonSubTypes.Type(value = X509LwM2MBootstrapServerCredential.class, name = "X509") }) @JsonIgnoreProperties(ignoreUnknown = true) public interface LwM2MBootstrapServerCredential { diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java index 8973232b9a..7730c79ee9 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapLwM2MServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/NoSecLwM2MBootstrapServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class NoSecLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { +public class NoSecLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.NO_SEC; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java index 9adf566eb0..30f7f8c472 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapLwM2MServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/PSKLwM2MBootstrapServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class PSKLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { +public class PSKLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.PSK; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java index bf595a394b..c529820709 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapLwM2MServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/RPKLwM2MBootstrapServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class RPKLwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { +public class RPKLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.RPK; diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java similarity index 89% rename from common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java rename to common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java index 1c2d83ba8e..e95bf7742d 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapLwM2MServerCredential.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/profile/lwm2m/bootstrap/X509LwM2MBootstrapServerCredential.java @@ -17,7 +17,7 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap; import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode; -public class X509LwM2MBootstrapLwM2MServerCredential extends AbstractLwM2MBootstrapLwM2MServerCredential { +public class X509LwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential { @Override public LwM2MSecurityMode getSecurityMode() { return LwM2MSecurityMode.X509; diff --git a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java index 6552bcf1f8..5a7bf32518 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java +++ b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceProfileServiceImpl.java @@ -60,9 +60,9 @@ import org.thingsboard.server.common.data.device.profile.Lwm2mDeviceProfileTrans import org.thingsboard.server.common.data.device.profile.MqttDeviceProfileTransportConfiguration; import org.thingsboard.server.common.data.device.profile.ProtoTransportPayloadConfiguration; import org.thingsboard.server.common.data.device.profile.TransportPayloadTypeConfiguration; -import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapLwM2MServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.RPKLwM2MBootstrapServerCredential; import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.LwM2MBootstrapServerCredential; -import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapLwM2MServerCredential; +import org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap.X509LwM2MBootstrapServerCredential; import org.thingsboard.server.common.data.ota.OtaPackageType; import org.thingsboard.server.common.data.id.DeviceProfileId; import org.thingsboard.server.common.data.id.TenantId; @@ -419,8 +419,9 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D } } else if (transportConfiguration instanceof Lwm2mDeviceProfileTransportConfiguration) { LwM2MBootstrapServersConfiguration lwM2MBootstrapServersConfiguration = ((Lwm2mDeviceProfileTransportConfiguration) transportConfiguration).getBootstrap(); - validateLwm2mServersCredentialOfBootstrapForClient(lwM2MBootstrapServersConfiguration.getBootstrapServer(), "Bootstrap Server"); - validateLwm2mServersCredentialOfBootstrapForClient(lwM2MBootstrapServersConfiguration.getLwm2mServer(), "LwM2M Server"); + for (LwM2MBootstrapServerCredential bootstrapServerCredential : lwM2MBootstrapServersConfiguration.getServerConfiguration()) { + validateLwm2mServersCredentialOfBootstrapForClient(bootstrapServerCredential); + } } List profileAlarms = deviceProfile.getProfileData().getAlarms(); @@ -704,13 +705,15 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D } } - private void validateLwm2mServersCredentialOfBootstrapForClient(LwM2MBootstrapServerCredential bootstrapServerConfig, String server) { + private void validateLwm2mServersCredentialOfBootstrapForClient(LwM2MBootstrapServerCredential bootstrapServerConfig) { + String server; switch (bootstrapServerConfig.getSecurityMode()) { case NO_SEC: case PSK: break; case RPK: - RPKLwM2MBootstrapLwM2MServerCredential rpkServerCredentials = (RPKLwM2MBootstrapLwM2MServerCredential) bootstrapServerConfig; + RPKLwM2MBootstrapServerCredential rpkServerCredentials = (RPKLwM2MBootstrapServerCredential) bootstrapServerConfig; + server = rpkServerCredentials.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; if (StringUtils.isEmpty(rpkServerCredentials.getServerPublicKey())) { throw new DeviceCredentialsValidationException(server + " RPK public key must be specified!"); } @@ -723,7 +726,8 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D } break; case X509: - X509LwM2MBootstrapLwM2MServerCredential x509ServerCredentials = (X509LwM2MBootstrapLwM2MServerCredential) bootstrapServerConfig; + X509LwM2MBootstrapServerCredential x509ServerCredentials = (X509LwM2MBootstrapServerCredential) bootstrapServerConfig; + server = x509ServerCredentials.isBootstrapServerIs() ? "Bootstrap Server" : "LwM2M Server"; if (StringUtils.isEmpty(x509ServerCredentials.getServerPublicKey())) { throw new DeviceCredentialsValidationException(server + " X509 public key must be specified!"); }