Merge pull request #621 from ayyoob/cloud-3.1.0

added permission and subscription fix
revert-70aa11f8
Ayyoob Hamza 8 years ago committed by GitHub
commit f554f62e1d

@ -107,12 +107,14 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi
validityPeriod = registrationProfile.getValidityPeriod(); validityPeriod = registrationProfile.getValidityPeriod();
} }
String applicationName = "devicetype_app_" + StringUtils.join(registrationProfile.getTags(), "_"); String applicationName = registrationProfile.getApplicationName();
ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys( synchronized (ApiApplicationRegistrationServiceImpl.class) {
applicationName, registrationProfile.getTags(), ApiApplicationKey apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username, applicationName, registrationProfile.getTags(),
registrationProfile.isAllowedToAllDomains(), validityPeriod); ApiApplicationConstants.DEFAULT_TOKEN_TYPE, username,
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build(); registrationProfile.isAllowedToAllDomains(), validityPeriod);
return Response.status(Response.Status.CREATED).entity(apiApplicationKey.toString()).build();
}
} catch (APIManagerException e) { } catch (APIManagerException e) {
String msg = "Error occurred while registering an application with apis '" String msg = "Error occurred while registering an application with apis '"
+ StringUtils.join(registrationProfile.getTags(), ",") + "'"; + StringUtils.join(registrationProfile.getTags(), ",") + "'";

@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class RegistrationProfile { public class RegistrationProfile {
@XmlElement(required = true)
private String applicationName;
@XmlElement(required = true) @XmlElement(required = true)
private String tags[]; private String tags[];
@XmlElement(required = true) @XmlElement(required = true)
@ -37,6 +39,14 @@ public class RegistrationProfile {
@XmlElement(required = false) @XmlElement(required = false)
private String validityPeriod; private String validityPeriod;
public String getApplicationName() {
return applicationName;
}
public void setApiApplicationName(String apiApplicationName) {
this.applicationName = apiApplicationName;
}
public String[] getTags() { public String[] getTags() {
return tags; return tags;
} }

@ -30,7 +30,7 @@
"enabled": true, "enabled": true,
"issuer" : "devicemgt", "issuer" : "devicemgt",
"appName" : "devicemgt", "appName" : "devicemgt",
"identityProviderUrl" : "https://%carbon.local.ip%:%iot.keymanager.https.port%/samlsso", "identityProviderUrl" : "https://%iot.keymanager.host%:%iot.keymanager.https.port%/samlsso",
"acs": "https://%iot.manager.host%:%iot.manager.https.port%/devicemgt/uuf/sso/acs", "acs": "https://%iot.manager.host%:%iot.manager.https.port%/devicemgt/uuf/sso/acs",
"identityAlias": "wso2carbon", "identityAlias": "wso2carbon",
"responseSigningEnabled" : true, "responseSigningEnabled" : true,

@ -51,6 +51,16 @@ var operationModule = function () {
feature["contentType"] = features[i].contentType; feature["contentType"] = features[i].contentType;
feature["deviceType"] = deviceType; feature["deviceType"] = deviceType;
feature["params"] = []; feature["params"] = [];
var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"];
if (featuresEntry) {
var featureEntry = featuresEntry[features[i].code];
if (featureEntry) {
var permissionEntry = featureEntry["permission"];
if (permissionEntry) {
feature["permission"] = permissionEntry
}
}
}
var metaData = features[i].metadataEntries; var metaData = features[i].metadataEntries;
if (metaData) { if (metaData) {
for (var j = 0; j < metaData.length; j++) { for (var j = 0; j < metaData.length; j++) {

@ -511,7 +511,7 @@ var userModule = function () {
permissions["LIST_DEVICES"] = true; permissions["LIST_DEVICES"] = true;
permissions["LIST_OWN_DEVICES"] = true; permissions["LIST_OWN_DEVICES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/owning-device")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view")) {
permissions["LIST_OWN_DEVICES"] = true; permissions["LIST_OWN_DEVICES"] = true;
} }
if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) { if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/view")) {

@ -30,7 +30,10 @@ application.put("carbonServer", carbonServer);
var permissions = { var permissions = {
"/permission/admin/Login": ["ui.execute"], "/permission/admin/Login": ["ui.execute"],
"/permission/admin/device-mgt/device/api/subscribe": ["ui.execute"] "/permission/admin/device-mgt/device/api/subscribe": ["ui.execute"],
"/permission/admin/device-mgt/devices/enroll": ["ui.execute"],
"/permission/admin/device-mgt/devices/disenroll": ["ui.execute"],
"/permission/admin/device-mgt/devices/owning-device/view": ["ui.execute"]
}; };
var adminPermissions = { var adminPermissions = {

Loading…
Cancel
Save