Skip to content

Commit

Permalink
Further updates to code for finding oscore instance from security object
Browse files Browse the repository at this point in the history
Signed-off-by: Rikard Höglund <rikard.hoglund@ri.se>
  • Loading branch information
rikard-sics committed Jan 7, 2021
1 parent af75452 commit a811182
Showing 1 changed file with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,22 @@ public static ServersInfo getInfo(Map<Integer, LwM2mObjectEnabler> objectEnabler
LwM2mObjectInstance oscoreInstance = null;
ObjectLink oscoreObjLink = (ObjectLink) security.getResource(SEC_OSCORE_SECURITY_MODE)
.getValue();
if (oscoreObjLink != null) {
int oscoreObjectInstanceId = oscoreObjLink.getObjectInstanceId();
if (!oscoreObjLink.isNullLink() && oscoreObjLink.getObjectId() != OSCORE) {
if (oscoreObjLink != null && !oscoreObjLink.isNullLink()) {
if (oscoreObjLink.getObjectId() != OSCORE) {
LOG.warn(
"The security object's 'OSCORE Security Mode' links to an incorrect object type.");
"Invalid Security info for bootstrap server : 'OSCORE Security Mode' does not link to OSCORE Object but to {} object.",
oscoreObjLink.getObjectId());
} else {
oscoreInstance = oscores.getInstance(oscoreObjectInstanceId);
if (oscoreInstance == null) {
// maybe we should use same log level for this one and the other just above
LOG.error("Failed to retrieve OSCORE object linked from BS security object");
if (oscores == null) {
LOG.warn(
"Invalid Security info for bootstrap server : OSCORE object enabler is not available.");
} else {
oscoreInstance = oscores.getInstance(oscoreObjLink.getObjectInstanceId());
if (oscoreInstance == null) {
LOG.warn(
"Invalid Security info for bootstrap server : OSCORE instance {} does not exist.",
oscoreObjLink.getObjectInstanceId());
}
}
}
}
Expand Down Expand Up @@ -143,15 +149,22 @@ public static ServersInfo getInfo(Map<Integer, LwM2mObjectEnabler> objectEnabler
// find associated oscore instance (if any)
LwM2mObjectInstance oscoreInstance = null;
ObjectLink oscoreObjLink = (ObjectLink) security.getResource(SEC_OSCORE_SECURITY_MODE).getValue();
if (oscoreObjLink != null) {
int oscoreObjectInstanceId = oscoreObjLink.getObjectInstanceId();
if (!oscoreObjLink.isNullLink() && oscoreObjLink.getObjectId() != OSCORE) {
LOG.warn("The security object's 'OSCORE Security Mode' links to an incorrect object type.");
if (oscoreObjLink != null && !oscoreObjLink.isNullLink()) {
if (oscoreObjLink.getObjectId() != OSCORE) {
LOG.warn(
"Invalid Security info for LWM2M server : 'OSCORE Security Mode' does not link to OSCORE Object but to {} object.",
oscoreObjLink.getObjectId());
} else {
oscoreInstance = oscores.getInstance(oscoreObjectInstanceId);
if (oscoreInstance == null) {
// maybe we should use same log level for this one and the other just above
LOG.error("Failed to retrieve OSCORE object linked from DM security object");
if (oscores == null) {
LOG.warn(
"Invalid Security info for LWM2M server : OSCORE object enabler is not available.");
} else {
oscoreInstance = oscores.getInstance(oscoreObjLink.getObjectInstanceId());
if (oscoreInstance == null) {
LOG.warn(
"Invalid Security info for LWM2M server : OSCORE instance {} does not exist.",
oscoreObjLink.getObjectInstanceId());
}
}
}
}
Expand Down

0 comments on commit a811182

Please sign in to comment.