Merge pull request 'fixed adding operation and operation response paths with emqx integration' (#85) from amalka.subasinghe/device-mgt-core:master into master

Reviewed-on: community/device-mgt-core#85
scep-fix
Charitha Goonetilleke 2 years ago
commit 0ae4ff68a6

@ -872,6 +872,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
DeviceManagementProviderService deviceManagementProviderService = DeviceManagementProviderService deviceManagementProviderService =
DeviceMgtAPIUtils.getDeviceManagementService(); DeviceMgtAPIUtils.getDeviceManagementService();
int validityTime = 3600; int validityTime = 3600;
// add scopes for event topics
List<String> mqttEventTopicStructure = new ArrayList<>(); List<String> mqttEventTopicStructure = new ArrayList<>();
try { try {
DeviceType deviceType = deviceManagementProviderService.getDeviceType(type); DeviceType deviceType = deviceManagementProviderService.getDeviceType(type);
@ -912,10 +913,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
topic = topic.replace("${deviceId}", id); topic = topic.replace("${deviceId}", id);
} }
topic = topic.replace("/",":"); topic = topic.replace("/",":");
scopes.append(" perm:topic:sub:".concat(topic)); // scopes.append(" perm:topic:sub:".concat(topic));
scopes.append(" perm:topic:pub:".concat(topic)); scopes.append(" perm:topic:pub:".concat(topic));
} }
// add scopes for retrieve operation topic /tenantDomain/deviceType/deviceId/operation/#
scopes.append(" perm:topic:sub:" + tenantDomain + ":" + type + ":" + id + ":operation");
// add scopes for update operation /tenantDomain/deviceType/deviceId/update/operation
scopes.append(" perm:topic:pub:" + tenantDomain + ":" + type + ":" + id + ":update:operation");
TokenRequest tokenRequest = new TokenRequest(dcrResponse.getClientId(), dcrResponse.getClientSecret(), TokenRequest tokenRequest = new TokenRequest(dcrResponse.getClientId(), dcrResponse.getClientSecret(),
null, scopes.toString(), "client_credentials", null, null, scopes.toString(), "client_credentials", null,
null, null, null, validityTime); null, null, null, validityTime);

Loading…
Cancel
Save