Skip to content

Commit

Permalink
Merge pull request #3973 from MDeLuise/feature-tamper
Browse files Browse the repository at this point in the history
Add parsing for `tamper_status` property in birth message
  • Loading branch information
Coduz authored Feb 21, 2024
2 parents b5f9539 + afacff3 commit c7c55f4
Show file tree
Hide file tree
Showing 22 changed files with 223 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ devEsfVersion=KURA/ESF Version
devNumProc=Number of Processors
devRamTot=Total RAM
devRamFree=Free RAM
devTamperStatus=Tamper status

netConnIface=Network Interface
netConnIfaceIp=Network Interface IP Address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
*******************************************************************************/
package org.eclipse.kapua.app.console.module.device.server;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

import com.extjs.gxt.ui.client.data.BaseListLoadResult;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
Expand Down Expand Up @@ -72,12 +78,6 @@
import org.eclipse.kapua.service.user.User;
import org.eclipse.kapua.service.user.UserService;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

/**
* The server side implementation of the Device RPC service.
*/
Expand Down Expand Up @@ -254,6 +254,7 @@ public User call() throws Exception {
pairs.add(new GwtGroupedNVPair(DEV_HW, "devModelId", device.getModelId()));
pairs.add(new GwtGroupedNVPair(DEV_HW, "devModelName", device.getModelName()));
pairs.add(new GwtGroupedNVPair(DEV_HW, "devSerialNumber", device.getSerialNumber()));
pairs.add(new GwtGroupedNVPair(DEV_HW, "devTamperStatus", device.getTamperStatus()));

pairs.add(new GwtGroupedNVPair(DEV_SW, "devFirmwareVersion", device.getFirmwareVersion()));
pairs.add(new GwtGroupedNVPair(DEV_SW, "devBiosVersion", device.getBiosVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,20 @@ public interface KapuaBirthPayload extends KapuaLifecyclePayload {
* @since 1.5.0
*/
void setExtendedProperties(String extendedProperties);

/**
* Gets the tamper status
*
* @return The tamper status.
* @since 2.0.0
*/
String getTamperStatus();

/**
* Sets the tamper status.
*
* @param tamperStatus The tamper status.
* @since 1.5.0
*/
void setTamperStatus(String tamperStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,9 @@ private KapuaBirthPayloadAttibutes() {
* @since 1.5.0
*/
public static final String EXTENDED_PROPERTIES = "extendedProperties";

/**
* @since 2.0.0
*/
public static final String TAMPER_STATUS = "tamperStatus";
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public KapuaAppsPayloadImpl(String uptime,
String modemImei,
String modemImsi,
String modemIccid,
String extendedProperties) {
String extendedProperties,
String tamperStatus) {
super(uptime,
displayName,
modelName,
Expand Down Expand Up @@ -96,6 +97,7 @@ public KapuaAppsPayloadImpl(String uptime,
modemImei,
modemImsi,
modemIccid,
extendedProperties);
extendedProperties,
tamperStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public KapuaBirthPayloadImpl() {
* @param modemImsi The {@link KapuaBirthPayloadAttibutes#MODEM_IMSI} of the {@link KapuaBirthMessage}
* @param modemIccid The {@link KapuaBirthPayloadAttibutes#MODEM_ICCID} of the {@link KapuaBirthMessage}
* @param extendedProperties The {@link KapuaBirthPayloadAttibutes#EXTENDED_PROPERTIES} of the {@link KapuaBirthMessage}
* @param tamperStatus The {@link KapuaBirthPayloadAttibutes#TAMPER_STATUS} of the {@link KapuaBirthMessage}
* @since 1.0.0
*/
public KapuaBirthPayloadImpl(String uptime,
Expand Down Expand Up @@ -100,7 +101,8 @@ public KapuaBirthPayloadImpl(String uptime,
String modemImei,
String modemImsi,
String modemIccid,
String extendedProperties) {
String extendedProperties,
String tamperStatus) {

setUptime(uptime);
setDisplayName(displayName);
Expand Down Expand Up @@ -132,6 +134,7 @@ public KapuaBirthPayloadImpl(String uptime,
setModemImsi(modemImsi);
setModemIccid(modemIccid);
setExtendedProperties(extendedProperties);
setTamperStatus(tamperStatus);
}

@Override
Expand Down Expand Up @@ -433,4 +436,14 @@ public String getExtendedProperties() {
public void setExtendedProperties(String extendedProperties) {
getMetrics().put(KapuaBirthPayloadAttibutes.EXTENDED_PROPERTIES, extendedProperties);
}

@Override
public String getTamperStatus() {
return (String) getMetrics().get(KapuaBirthPayloadAttibutes.TAMPER_STATUS);
}

@Override
public void setTamperStatus(String temperStatus) {
getMetrics().put(KapuaBirthPayloadAttibutes.TAMPER_STATUS, temperStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class KapuaAppsMessageTest {
"~~osVersion=osV-1" +
"~~partNumber=part-1" +
"~~serialNumber=SN-123" +
"~~tamperStatus=NOT_TAMPERED" +
"~~totalMemory=4" +
"~~uptime=12";

Expand Down Expand Up @@ -161,7 +162,8 @@ private static KapuaAppsPayload populateKapuaAppsPayload() {
" \"propertyName\": \"propertyValue\"\n" +
" }\n" +
" }\n" +
"}"
"}",
"NOT_TAMPERED"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class KapuaBirthMessageTest {
"~~osVersion=osV-1" +
"~~partNumber=part-1" +
"~~serialNumber=SN-123" +
"~~tamperStatus=NOT_TAMPERED" +
"~~totalMemory=4" +
"~~uptime=12";

Expand Down Expand Up @@ -165,7 +166,8 @@ private static KapuaBirthPayload populateKapuaBirthPayload() {
" \"propertyName\": \"propertyValue\"\n" +
" }\n" +
" }\n" +
"}"
"}",
"NOT_TAMPERED"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
*******************************************************************************/
package org.eclipse.kapua.qa.common;

import java.time.Duration;
import java.util.Date;
import java.util.Map;
import javax.inject.Inject;

import com.google.common.base.Strings;
import com.google.inject.Singleton;
import io.cucumber.java.After;
Expand Down Expand Up @@ -57,11 +62,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.time.Duration;
import java.util.Date;
import java.util.Map;

@Singleton
public class BasicSteps extends TestBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ paths:
groupName: Hardware Info
name: CPU Cores
value: 4
tamperStatus: NOT_TAMPERED
tagIds: [ ]
required: true
responses:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ paths:
connectionIp: 127.0.0.1
applicationIdentifiers: heaterPROV-V2DEPLOY-V2VPNCLIENT-V2CONF-V1CERT-V1ASSET-V1CMD-V1
acceptEncoding: gzip
tamperStatus: NOT_TAMPERED
tagIds: []
with-fetch-attributes:
value:
Expand Down Expand Up @@ -158,6 +159,7 @@ paths:
connectionIp: 127.0.0.1
applicationIdentifiers: heaterPROV-V2DEPLOY-V2VPNCLIENT-V2CONF-V1CERT-V1ASSET-V1CMD-V1
acceptEncoding: gzip
tamperStatus: NOT_TAMPERED
tagIds: []

401:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ components:
customAttribute5:
description: A Custom Attribute of this Device - 5
type: string
tamperStatus:
description: The tamper status of the Device
type: string
extendedProperties:
type: array
items:
Expand Down Expand Up @@ -177,6 +180,7 @@ components:
groupName: Hardware Info
name: CPU Cores
value: 4
tamperStatus: NOT_TAMPERED
tagIds: [ ]
deviceCreator:
allOf:
Expand Down Expand Up @@ -264,6 +268,9 @@ components:
customAttribute5:
description: A Custom Attirbute of this Device - 5
type: string
tamperStatus:
description: The tamper status of the Device
type: string
tagIds:
description: A list of tag ID to link to the Device
type: array
Expand All @@ -285,6 +292,7 @@ components:
osgiFrameworkVersion: 1.7.0
acceptEncoding: gzip
deviceCredentialsMode: LOOSE
tamperStatus: NOT_TAMPERED
tagIds: []
deviceListResult:
allOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ public class AbstractKuraAppsBirthPayload extends AbstractKuraLifecyclePayload i
* @since 1.0.0
*/
protected static final String DEFAULT_APPLICATION_FRAMEWORK = "Kura";

/**
* {@link Device} tamper status.
*
* @since 2.0.0
*/
protected static final String TAMPER_STATUS = "tamper_status";

private static final long serialVersionUID = 5490945197263668115L;


Expand Down Expand Up @@ -283,6 +291,7 @@ public AbstractKuraAppsBirthPayload() {
* @param modemImsi {@link Device} modem IMSI.
* @param modemIccid {@link Device} modem ICCID.
* @param extendedProperties {@link Device} extended properties.
* @param tamperStatus {@link Device} tamper status.
* @since 1.0.0
*/
public AbstractKuraAppsBirthPayload(String uptime,
Expand Down Expand Up @@ -312,7 +321,8 @@ public AbstractKuraAppsBirthPayload(String uptime,
String modemImei,
String modemImsi,
String modemIccid,
String extendedProperties) {
String extendedProperties,
String tamperStatus) {
super();

if (uptime != null) {
Expand Down Expand Up @@ -399,6 +409,9 @@ public AbstractKuraAppsBirthPayload(String uptime,
if (extendedProperties != null) {
getMetrics().put(EXTENDED_PROPERTIES, extendedProperties);
}
if (tamperStatus != null) {
getMetrics().put(TAMPER_STATUS, tamperStatus);
}
}

/**
Expand Down Expand Up @@ -713,5 +726,15 @@ public String getExtendedProperties() {
return (String) getMetrics().get(EXTENDED_PROPERTIES);
}

/**
* Gets the {@link Device} tamper status.
*
* @return The {@link Device} extended properties.
* @since 2.0.0
*/
public String getTamperStatus() {
return (String) getMetrics().get(TAMPER_STATUS);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"customAttribute4",
"customAttribute5",
"extendedProperties",
"tamperStatus",
"tagIds"
}, factoryClass = DeviceXmlRegistry.class, factoryMethod = "newDevice")
public interface Device extends KapuaUpdatableEntity {
Expand Down Expand Up @@ -603,4 +604,21 @@ default String getType() {
* @since 1.5.0
*/
void setExtendedProperties(List<DeviceExtendedProperty> extendedProperties);

/**
* Gets the tamper status.
*
* @return The tamper status.
* @since 2.0.0
*/
@XmlElement(name = "tamperStatus")
String getTamperStatus();

/**
* Sets the tamper status.
*
* @param tamperStatus The tamper status.
* @since 2.0.0
*/
void setTamperStatus(String tamperStatus);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"customAttribute4",
"customAttribute5",
"extendedProperties",
"tagIds"
"tagIds",
"tamperStatus"
}, factoryClass = DeviceXmlRegistry.class, factoryMethod = "newDeviceCreator")
public interface DeviceCreator extends KapuaUpdatableEntityCreator<Device> {

Expand Down Expand Up @@ -560,6 +561,23 @@ public interface DeviceCreator extends KapuaUpdatableEntityCreator<Device> {
*/
void setExtendedProperties(List<DeviceExtendedProperty> extendedProperties);

/**
* Gets the tamper status.
*
* @return The application tamper status.
* @since 2.0.0
*/
@XmlElement(name = "tamperStatus")
String getTamperStatus();

/**
* Sets the tamper status.
*
* @param tamperStatus The tamper status.
* @since 2.0.0
*/
void setTamperStatus(String tamperStatus);


/**
* Gets the list of tags associated with the device.
Expand Down
Loading

0 comments on commit c7c55f4

Please sign in to comment.