Skip to content

Commit

Permalink
Adapt Server input to prepare to add OSCORE support to BS server demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Jun 7, 2022
1 parent ac05acf commit da8e50b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
class="examplePatch"
></v-text-field>
<security-input
:mode.sync="server.mode"
:mode.sync="server.security.mode"
@update:mode="$emit('input', server)"
:details.sync="server.details"
:details.sync="server.security.details"
@update:details="$emit('input', server)"
:defaultrpk="defaultrpk"
:defaultx509="defaultx509"
Expand All @@ -46,27 +46,27 @@ export default {
defaultNoSecValue: String,
defaultSecureValue: String,
defaultrpk: {
default: function() {
default: function () {
return {};
},
type: Object,
},
defaultx509: {
default: function() {
default: function () {
return {};
},
type: Object,
},
},
data() {
return {
server: { mode: "no_sec" }, // internal server Config
server: { security: { mode: "no_sec" } }, // internal server Config
};
},
watch: {
value(v) {
if (!v) {
this.server = { mode: "no_sec" };
this.server = { security: { mode: "no_sec" } };
} else {
this.server = v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
<v-card-text class="pb-0">
<p>
This information will be used to add a
<strong>LWM2M Bootstrap Server</strong> to your LWM2M Client during the bootstrap
Session by writing 1 instance for object <code>/0</code>.
</p>
<p>
By default no LWM2M Bootstrap server is added.
<strong>LWM2M Bootstrap Server</strong> to your LWM2M Client during the
bootstrap Session by writing 1 instance for object <code>/0</code>.
</p>
<p>By default no LWM2M Bootstrap server is added.</p>
</v-card-text>
<v-form
ref="form"
Expand Down Expand Up @@ -60,14 +58,14 @@ export default {
data() {
return {
addServer: false,
internalServer: { mode: "no_sec" }, // internal Bootstrap server Config
internalServer: { security: { mode: "no_sec" } }, // internal Bootstrap server Config
};
},
watch: {
value(v) {
if (!v) {
this.addServer = false;
this.internalServer = { mode: "no_sec" };
this.internalServer = { security: { mode: "no_sec" } };
} else {
this.addServer = true;
this.internalServer = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@
>
Previous
</v-btn>
<v-btn text @click="close">
Cancel
</v-btn>
<v-btn text @click="close"> Cancel </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
Expand Down Expand Up @@ -193,7 +191,7 @@ export default {
this.config = {
endpoint: null,
security: null,
dm: { mode: "no_sec" },
dm: { security: { mode: "no_sec" } },
bs: null,
toDelete: ["/0", "/1"],
autoIdForSecurityObject: false,
Expand All @@ -217,7 +215,7 @@ export default {
if (res.dm) {
if (!res.dm.url) {
res.dm.url =
res.dm.mode == "no_sec"
res.dm.security.mode == "no_sec"
? this.defval.dm.url.nosec
: this.defval.dm.url.sec;
}
Expand All @@ -226,24 +224,24 @@ export default {
if (res.bs) {
if (!res.bs.url) {
res.bs.url =
res.bs.mode == "no_sec"
res.bs.security.mode == "no_sec"
? this.defval.bs.url.nosec
: this.defval.bs.url.sec;
}
// apply default rpk value for bs server
if (res.bs.mode == "rpk") {
if (res.bs.security.mode == "rpk") {
for (const key in this.defaultrpk) {
if (!res.bs.details[key]) {
res.bs.details[key] = this.defaultrpk[key];
if (!res.bs.security.details[key]) {
res.bs.security.details[key] = this.defaultrpk[key];
}
}
}
// apply default x509 value for bs server
if (res.bs.mode == "x509") {
if (res.bs.security.mode == "x509") {
for (const key in this.defaultx509) {
if (!res.bs.details[key]) {
res.bs.details[key] = this.defaultx509[key];
if (!res.bs.security.details[key]) {
res.bs.security.details[key] = this.defaultx509[key];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export default {
data() {
return {
addServer: true,
internalServer: { mode: "no_sec" }, // internal server Config
internalServer: { security: { mode: "no_sec" } }, // internal server Config
};
},
watch: {
value(v) {
if (!v) {
this.addServer = false;
this.internalServer = { mode: "no_sec" };
this.internalServer = { security: { mode: "no_sec" } };
} else {
this.addServer = true;
this.internalServer = v;
Expand Down
22 changes: 11 additions & 11 deletions leshan-bsserver-demo/webapp/src/views/Bootstrap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,23 @@ export default {
formatData(c) {
let s = {};
s.securityMode = c.mode.toUpperCase();
s.securityMode = c.security.mode.toUpperCase();
s.uri = c.url;
switch (c.mode) {
switch (c.security.mode) {
case "psk":
s.publicKeyOrId = fromAscii(c.details.identity);
s.secretKey = fromHex(c.details.key);
s.publicKeyOrId = fromAscii(c.security.details.identity);
s.secretKey = fromHex(c.security.details.key);
break;
case "rpk":
s.publicKeyOrId = fromHex(c.details.client_pub_key);
s.secretKey = fromHex(c.details.client_pri_key);
s.serverPublicKey = fromHex(c.details.server_pub_key);
s.publicKeyOrId = fromHex(c.security.details.client_pub_key);
s.secretKey = fromHex(c.security.details.client_pri_key);
s.serverPublicKey = fromHex(c.security.details.server_pub_key);
break;
case "x509":
s.publicKeyOrId = fromHex(c.details.client_certificate);
s.secretKey = fromHex(c.details.client_pri_key);
s.serverPublicKey = fromHex(c.details.server_certificate);
s.certificateUsage = c.details.certificate_usage;
s.publicKeyOrId = fromHex(c.security.details.client_certificate);
s.secretKey = fromHex(c.security.details.client_pri_key);
s.serverPublicKey = fromHex(c.security.details.server_certificate);
s.certificateUsage = c.security.details.certificate_usage;
break;
}
return s;
Expand Down

0 comments on commit da8e50b

Please sign in to comment.